request
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));
const request = new Request();
request.onError(err => {
console.warn(err);
});
// yarn add cross-fetch
import 'cross-fetch/polyfill';
MIT