mirror of
https://github.com/tenrok/axios.git
synced 2026-06-17 19:21:29 +03:00
update example according to feedback from PR
This commit is contained in:
@@ -521,28 +521,11 @@ axios.get('/user/12345', {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// cancel the request (the message parameter is optional)
|
axios.post('/user/12345', {
|
||||||
source.cancel('Operation canceled by the user.');
|
name: 'new name'
|
||||||
```
|
}, {
|
||||||
|
cancelToken: source.token
|
||||||
```js
|
})
|
||||||
var CancelToken = axios.CancelToken;
|
|
||||||
var source = CancelToken.source();
|
|
||||||
|
|
||||||
axios(
|
|
||||||
method: 'POST',
|
|
||||||
url: '/user/12345',
|
|
||||||
data: {
|
|
||||||
name: 'new name'
|
|
||||||
},
|
|
||||||
cancelToken: source.token
|
|
||||||
}).catch(function(thrown) {
|
|
||||||
if (axios.isCancel(thrown)) {
|
|
||||||
console.log('Request canceled', thrown.message);
|
|
||||||
} else {
|
|
||||||
// handle error
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// cancel the request (the message parameter is optional)
|
// cancel the request (the message parameter is optional)
|
||||||
source.cancel('Operation canceled by the user.');
|
source.cancel('Operation canceled by the user.');
|
||||||
|
|||||||
Reference in New Issue
Block a user