title: Cancel axios get request when typing reactjs
body: <p>I'm creating an autocomplete function, so basically whenever I type on search box it will cancel the previous http get request. I checked the jQuery ui autocomplete and that's what they did. Is that possible in axios if yes how can I implement it. So far here's my code for http get request:</p>
  
  <pre><code>export function autocompleteSearchTest(value){
      return axios.get(`https://jqueryui.com/resources/demos/autocomplete/search.php`,{
          params: {
              q: value
          }
      })
      .then(response =&gt; {
          return response.data.response;
      })
      .catch(error =&gt; {
          const result = error.response;
          return Promise.reject(result);
      });
  }
  </code></pre>
  
  <p><strong>Here's the screenshot when I type on the search box:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/O0wDK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/O0wDK.png" alt="enter image description here"></a></p>
  
  <p>as you can see it doesn't cancel the previous http get request.</p>