Promisify backend API to frontend
Usage
; // define your API mapvar APIS = name: 'blog' url: '/blogs/:id' name: 'comment' url: '/comments' ; var config = headers: 'Content-type': 'application/json' withCredentials: true; var service = config; service; ;
; APIblog ;
API
; /** * config * */config;
Installation
$ npm install simplehttpservice --save
Difference with fetch
Rules
// rule is a function you can get response and decide resolve/reject before Application code { if !xhrheaders'X-header' return ; ;} var service = rules: rule ;
Formatter
// formatter can help you format response to Application code // For instance, you backend API is: { data: { id, name } }// let's format it to { id, name } { var data = JSON; return JSON;} var service = formatter: formatter ;
License
MIT