Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to cancel request using axios cancel token

  const source = CancelToken.source();
  const timeout = setTimeout(() => {
    source.cancel();
    // Timeout Logic
  }, 10000);
  
  axios.get(ip + '/config', {cancelToken: source.token}).then((result) => {
    // Clear The Timeout
    clearTimeout(timeout);

    // Handle your response
  });
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #cancel #request #axios #cancel #token
ADD COMMENT
Topic
Name
3+1 =