An wrapper for axios.js
The new version has significant changes and is not compatible with the old version.
Compared with the old version, it is used in a very similar way to Axios.
- Axios-Like Methods
- Cancel Repeated Requests
- Retry
- Response Storage
- Broken Network Retransmission
- Handlers for Http-Status-Code Responses
- Cancel All Requests Matched By Filter
import AxiosSugar from 'axios-sugar';
// suppose the request returns paramA
AxiosSugar.get('/somePath', {
params: {
paramA: 1
}
}).then(res => {
console.log(res.data); // 1
})
Look, it's really like Axios!The request, get, post, delete, put, patch, head, options is also.
The difference is that these methods also receive an AxiosSugarConfig type parameter. e.g.
AxiosSugar.get('/somePath', {
params: {
paramA: 1
}
}, {
retry: {
enable: true
}
})
Next, you should get more details in references
Node test:
npm test
Some browser test(e.g. AxiosSugarLocalStorage)
:
open the corresponding index.html
File in /test
which built by mocha.