/fetchu.js

A simple and modern fetch wrapper for Node.js

Primary LanguageTypeScriptOtherNOASSERTION

fetchu.js

A simple and modern fetch wrapper for Node.js

Installation

npm install fetchu.js

Usage

const { request, RequestMethod } = require('fetchu.js');

request('https://example.com', {
    method: RequestMethod.Get,
    headers: {
        'Content-Type': 'application/json'
    },
    body: {
        foo: 'bar'
    }
}, {
    isOk: (response) => console.log(`API responded successful ${response.status} ${response.statusText}!`),
    isNotOk: (response) => console.log(`API responded unsuccessful ${response.status} ${response.statusText}!`)
});