Numbers Probably Matter

    @ambassify/fetch-api

    4.0.0 • Public • Published

    fetch-api

    CircleCI npm version npm downloads maintainer

    Small class to create easy to use API clients with fetch. It uses @ambassify/fetch under the hood to provide a default fetch implementation for browser and node.

    Usage

    Install the package in your project:

    npm install --save @ambassify/fetch-api

    In your code:

    const FetchApi = require('@ambassify/fetch-api');
    
    const api = new FetchApi({
        baseUrl: 'https://your-api.test',
        contentType: 'FORM',
    });
    
    api.get('/foo', { offset: 1, limit: 1 })
        .then(res => console.log(res.body))
        .catch(err => console.log(err));
    
    api.post('/foo', { foo: 'bar' });
    api.put('/foo/1', { foo: 'bar' });
    api.patch('/foo/1', { foo: 'bar' });
    api.delete('/foo/1');

    Install

    npm i @ambassify/fetch-api

    DownloadsWeekly Downloads

    60

    Version

    4.0.0

    License

    MIT

    Unpacked Size

    36.1 kB

    Total Files

    27

    Last publish

    Collaborators

    • jorgenevens
    • sitebase
    • ambassify