frest.js — Facade REST — Send multiple HTTP REST API requests in one go and get aggregated response
A typical web application generally needs to sends multiple HTTP REST API requests one by one and then process their response. Managing multiple promise callbacks are tedious.
That’s why frest.js exists.
Install
You can get it from npm repository.
npm install frestjs --save
Setup
First, include the script located on the distfolder.
<script src="node_modules/frestjs/dist/frest.js"></script>Or you can use CDN Server
Usage
casecaded() — Sends multiple HTTP REST request by casecading response parameters
There are situation when one HTTP REST APIs response needs to be processed to get some parameter and this parameter needs to be passed to next HTTP REST requests.
casecaded() function does this for you.
Example
waterfall() — Sends multiple HTTP REST request one by one
To send HTTP REST requests one after another you can use waterfall() function.
getAll() — Sends multiple GET requests
A pretty common use case is to fetch multiple resources from different REST APIs.
getAll() accepts array of REST API urls and returns a promise object whose response contains aggregated response of all REST APIs.
postAll() — sends multiple POST requests
putAll() — sends multiple PUT requests
It is similar to postAll() requests.
deleteAll() — Sends multiple DELETE requests
deleteAll() accepts array of REST API urls and returns a promise object whose response contains aggregated response of all REST APIs.
Using frest.js in Angular 6
GitHub repository:
Cheers!!
