frest.js — Facade REST — Send multiple HTTP REST API requests in one go and get aggregated response

Balram Chavan
Sep 2, 2018 · 2 min read

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.

Balram Chavan

Written by

Full Stack Developer, GitHub Developer Program Member, Angular enthusiast! https://www.linkedin.com/in/balram-chavan

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade