Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/atomita/http-resource
https://github.com/atomita/http-resource
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/atomita/http-resource
- Owner: atomita
- License: mit
- Created: 2015-12-19T08:37:00.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-05-17T09:17:19.000Z (over 8 years ago)
- Last Synced: 2024-10-01T10:38:54.639Z (about 1 month ago)
- Language: wisp
- Size: 20.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# http-resource
This is like the angular-resource.
Abstracts a access to the resource (Web API).## Installation
### npm
```sh
npm install http-resource
```### jspm
```sh
jspm install npm:http-resource
```## Usage
```js
import httpResource from "http-resource";var UserResource = httpResource("/api/user/:id/:edit", {
actions: {
save: { method: "PUT" },
edit: { method: "GET", params: {"edit": "edit"} }
},
params: {
edit: ""
}
});// method override
class User extends UserResource {
save(params = {}, options = {}){
options["header"] = { "X-FOO": "foo" };
return super.save(params, options);
}
}User.get({"id":1}).then((user)=>{
user.name = "foo";
user.save();
});
```