Axios Resources
It’s a module that creates a resource object that lets you interact with RESTful server-side data sources.
Based on Angular ngResources.
Requirements
- Axios
- Lodash
Examples
const AxiosResources = ; //////////////////////////////////////////////////////////// //Axios Resource initial configconst objConfig = host: 'https://jsonplaceholder.typicode.com'; //Axios Resource Instanceconst objAxiosResources = ; //Post Sourceconst objPostSource = objAxiosResourcessource'posts' getById: method: 'GET' endpoint: 'posts/:id' params: 'id' getPostComments: method: 'GET' endpoint: 'posts/:id/comments' params: 'id' ; //////////////////////////////////////////////////////////// // GET https://jsonplaceholder.typicode.com/posts HTTP/1.1objPostSource; // GET https://jsonplaceholder.typicode.com/posts?userId=1 HTTP/1.1objPostSource; // POST https://jsonplaceholder.typicode.com/posts HTTP/1.1const objCreatePayload = title: 'foo' body: 'bar' userId: 1; objPostSource; // PUT https://jsonplaceholder.typicode.com/posts/1 HTTP/1.1const objUpdatePayload = id: 1 // This will be added to the URL title: 'foo2' body: 'bar' userId: 1; objPostSource; // DELETE https://jsonplaceholder.typicode.com/posts/1 HTTP/1.1const objDeletePayload = id: 1 // This will be added to the URL; objPostSource; // GET https://jsonplaceholder.typicode.com/posts/1 HTTP/1.1const objGetSinglePayload = id: 1 // This will be added to the URL; objPostSource; // GET https://jsonplaceholder.typicode.com/posts/1/comments HTTP/1.1const objGetCommentsPayload = id: 1 // This will be added to the URL; objPostSource;