Sarala JS
Javascript library to communicate with RESTful API built following JSON API specification. inspired by Laravel’s Eloquent
API Documentation | Background Story
Install
$ npm i sarala --save
$ yarn add sarala
Basic Usage
Model Implementation
app/models/BaseModel.js
;; { return 'https://sarala-demo.app/api'; } { return axios; }
app/models/Post.js
;; { return 'posts'; } { return 'title' 'subtitle' 'body' 'slug'; } { return tags: ; }
app/models/Tag.js
; { return 'tags'; } { return 'name'; }
Fetching data
; const post = ; // makes a GET request to https://sarala-demo.app/api/postsconst fetchAllPosts = async { let posts = await postall;};
Insert
app/components/MyComponent.js
; const tag = ;tagname = 'json-api'; // makes a POST request to https://sarala-demo.app/api/tagstag; // or you can directly call tag.create();
Change log
Please see CHANGELOG for more information on what has changed recently.