//Block one (will run once): cancelToken and source declaration
     const CancelToken = axios.CancelToken;
     let source = CancelToken.source();

 // Block two (will run before every request):
     source && source.cancel('Operation canceled due to new request.');

     // save the new request for cancellation
     source = axios.CancelToken.source();

     axios.post(url, postData, {
         cancelToken: source.token
     axios.get(url, {
         cancelToken: source.token

Leave a Reply

Your email address will not be published. Required fields are marked *