@swiftcarrot/request

0.2.2 • Public • Published

request

npm npm Build Status codecov styled with prettier

request

Usage

import Request from '@swiftcarrot/request';

const req = new Request('https://api.example.com/v1').timeout(5000);

req.get('/articles', { page: 1 });
req
  .post('/login', { name: 'test', password: '123' })
  .then(({ token }) => req.token(token));
req.post('/articles', { title: 'test' });
req.delete('/logout').then(() => req.token(null));

onError

const request = new Request();

request.onError(err => {
  console.warn(err);
});

add fetch Polyfill

// yarn add cross-fetch
import 'cross-fetch/polyfill';

License

MIT

/@swiftcarrot/request/

    Package Sidebar

    Install

    npm i @swiftcarrot/request

    Weekly Downloads

    4

    Version

    0.2.2

    License

    MIT

    Unpacked Size

    12.6 kB

    Total Files

    5

    Last publish

    Collaborators

    • adjusted