Awesome
stackable-fetcher
A middleware-based HTTP client library based on node-fetch.
Install
npm install stackable-fetcher
Usage
stackable-fetcher
provides Fetcher
class.
This class has #get
, #post
, #delete
and other HTTP methods that return Promise
.
import Fetcher from 'stackable-fetcher'
const fetcher = new Fetcher();
fetcher.get('https://github.com/').then(({ body, headers, status }) => {
console.log(body);
});
Middleware
stackable-fetcher is easily extended via middleware stack.
Specs
- A middleware is a constructor function that takes an application and options
- A middleware instance has
#call(request)
property that returns a promise
Example middlewares
Example usage
import { Fetcher, RequestLogger, ResponseLogger } from 'stackable-fetcher'
new Fetcher()
.use(RequestLogger)
.use(ResponseLogger)
.get('https://api.github.com/users/r7kamura');