Need private packages and team management tools?Check out npm Teams »

http-resource

1.0.2 • Public • Published

http-resource

This is like the angular-resource. Abstracts a access to the resource (Web API).

Installation

npm

npm install http-resource

jspm

jspm install npm:http-resource

Usage

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();
});

Keywords

none

Install

npm i http-resource

DownloadsWeekly Downloads

0

Version

1.0.2

License

MIT

Last publish

Collaborators

  • avatar