A small library for consuming a JsonAPI.
npm install --save jsonapi-jsimport { Resource } from "jsonapi-js";
export default class Endpoint extends Resource {
endpoint = "foo";
}
const foo = new Endpoint();
foo.findById(1).then(({ model, response }) => {
// model is a mash of attributes, and all merged relationships from includes
// resource is the raw response
});
foo.find({
include: ["some-relationship"],
filter: {
someKey: "baz"
}
}).then(({ model, response }) => {
// model is a mash of attributes, and all merged relationships from includes
// resource is the raw response
// model is an array in this case
});