https://github.com/tingge/enhanced-fetch
增强的fetch封装
https://github.com/tingge/enhanced-fetch
Last synced: 2 months ago
JSON representation
增强的fetch封装
- Host: GitHub
- URL: https://github.com/tingge/enhanced-fetch
- Owner: TingGe
- License: mit
- Created: 2019-02-20T05:07:24.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-27T02:29:46.000Z (over 7 years ago)
- Last Synced: 2025-06-22T01:49:55.470Z (about 1 year ago)
- Language: TypeScript
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# enhanced-fetch
增强的fetch封装
## Usage
```bash
$ npm install -S enhanced-fetch
```
```javascript
import { createRequest, applyRequestMiddleware } from 'enhanced-fetch';
const middlewares = applyRequestMiddleware(
// some middleware for api, such as debug, log, cache, tracker and so on.
);
const request = createRequest(middlewares);
request('http://xxx.com/api', {
params: { aaa: 'aaa' },
method: 'post',
timeout: 5000,
}).then(response => {
console.log('Got server response', response);
});
```