Skip to content

r7kamura/stackable-fetcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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');

About

A middleware-based HTTP client library.

Resources

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published