@jkempema/fetch

1.0.4 • Public • Published

fetch

fetch function that allows middleware.

Usage

import fetch from 'fetch';

fetch.applyMiddleware( 
    ( request ) => {  
        request.headers.append( 'authorization', 'bearer ...' );
    },
    async ( request, response ) => {
        const data = await response.clone().json();
    },s
    ( request, error ) => {
        console.error( error );
    } 
);

const response = await fetch( 'http://...', { method: "GET" } );
const data = await response.json();

Readme

Keywords

none

Package Sidebar

Install

npm i @jkempema/fetch

Weekly Downloads

0

Version

1.0.4

License

MIT

Last publish

Collaborators

  • jkempema