A middleware-based HTTP client library based on node-fetch.
npm install stackable-fetcher
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);
});
stackable-fetcher is easily extended via middleware stack.
- A middleware is a constructor function that takes an application and options
- A middleware instance has
#call(request)
property that returns a promise
import { Fetcher, RequestLogger, ResponseLogger } from 'stackable-fetcher'
new Fetcher()
.use(RequestLogger)
.use(ResponseLogger)
.get('https://api.github.com/users/r7kamura');