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

/http-resource/

    Package Sidebar

    Install

    npm i http-resource

    Weekly Downloads

    2

    Version

    1.0.2

    License

    MIT

    Last publish

    Collaborators

    • atomita