2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00

Adding axios.isCancel method

This commit is contained in:
Nick Uraltsev
2016-09-21 18:47:37 -07:00
parent 920769d0d7
commit 216e2a6787
9 changed files with 31 additions and 4 deletions
+1 -2
View File
@@ -471,14 +471,13 @@ You can cancel a request using a *cancel token*.
You can create a cancel token using the `CancelToken.source` factory as shown below:
```js
var Cancel = axios.Cancel;
var CancelToken = axios.CancelToken;
var source = CancelToken.source();
axios.get('/user/12345', {
cancelToken: source.token
}).catch(function(thrown) {
if (thrown instanceof Cancel) {
if (axios.isCancel(thrown)) {
console.log('Request canceled', thrown.message);
} else {
// handle error