Axios-Sugar
A wrapper for axios
Axios-Like
Its usage is similar to Axios that easy to use.
Out of the box
All features can be used after simple configuration。
Custom
Through callback to ensure a certain degree of customization function.
# Axios-Like Usage
import AxiosSugar from 'axios-sugar';
AxiosSugar.get('/path/to/sevice', {
params: {
/**/
}
}, {
retry: {
enable: true
}
}).then(res => {
console.log(res.data);
}).catch(err => {
console.log(err.reason.message); // all errors are put in reason property
});
TIP
Similar points:
- AxiosSugar and axios
- AxiosSugar.create and axios.create
- AxiosSugar.defaults and axios.defaults
- AxiosSugar.isCancel and axios.isCancel
- A series of methods to send a request, such as request, get, post, delete
- AxiosSugar.interceptors
WARNING
They are not completely equivalent, just similar in usage.
# Features
- Axios-Like Methods
- Cancel Repeated Requests
- Retry
- Response Storage
- Broken Network Retransmission
- Handlers for Http-Status-Code Responses
- Cancel All Requests Matched By Filter
TIP
More informations about features in config