0

I want to cancel an Axios request when clicking the button in react js

I read Axios documentation but don't find it

Alireza Bagheri
  • 207
  • 3
  • 15

1 Answers1

0

You can use this from https://axios-http.com/docs/cancellation

const controller = new AbortController();
    
axios.get('/foo/bar', {
    signal: controller.signal
}).then(function(response) {
   //...
});

// cancel the request
controller.abort()
Jose Lopez
  • 1
  • 1
  • 1