https://github.com/swiftcarrot/request
HTTP client for web and React Native
https://github.com/swiftcarrot/request
Last synced: about 2 months ago
JSON representation
HTTP client for web and React Native
- Host: GitHub
- URL: https://github.com/swiftcarrot/request
- Owner: swiftcarrot
- License: mit
- Created: 2019-07-02T13:36:52.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-12-09T14:58:35.000Z (over 3 years ago)
- Last Synced: 2025-02-28T06:52:50.241Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 346 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# request
[](https://www.npmjs.com/package/@swiftcarrot/request)
[](https://www.npmjs.com/package/@swiftcarrot/request)
[](https://travis-ci.org/swiftcarrot/request)
[](https://codecov.io/gh/swiftcarrot/request)
[](https://github.com/prettier/prettier)request
### Usage
```javascript
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
```javascript
const request = new Request();request.onError(err => {
console.warn(err);
});
```### add fetch Polyfill
```javascript
// yarn add cross-fetch
import 'cross-fetch/polyfill';
```### License
MIT