What does CancelToken mean? Where's source ()?

   _this.source = _this.$ajax.CancelToken.source(); 

want to know what this code means, and why can you use it this way?

May.26,2021
The

axios.create method provides the cancalToken parameter to cancel the network request.


axios used to cancel requests
this document has document cancellation
CancelToken.source ()

.
const source = axios.CancelToken.source();//source

axios.get('/user/12345', {
  cancelToken: source.token
}).catch(function(thrown) {
  if (axios.isCancel(thrown)) {
    console.log('', thrown.message);
  } else {
    // handle error
  }
});
source.cancel(' catch');
The

source method is a factory method of CancelToken .

CancelToken.source = function source() {
  var cancel;
  var token = new CancelToken(function executor(c) {
    cancel = c;
  });
  return {
    token: token,
    cancel: cancel
  };
};

CancelToken

const CancelToken = axios.CancelToken;
let cancel;

axios.get('/user/12345', {
  cancelToken: new CancelToken(function executor(c) {
    // An executor function receives a cancel function as a parameter
    cancel = c;
  })
});

// cancel the request
cancel();
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3a053-4121f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3a053-4121f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?