Skip to content

swiftcarrot/request

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

HTTP client for web and React Native

Resources

License

Stars

Watchers

Forks

Packages

No packages published