In this post, we will be looking into AbortController
and how can we use it to cancel network requests.
We know that fetch
is a method that sends a network request and returns a promise, but what if we wanted to cancel this ongoing request.
For example, consider this scenario where we want to implement a search functionality that displays results during user input, however user typing speed can vary from one to another and we want to cancel the preceding request. We can do it by minimising the number of server requests using AbortController
.
#programming #fetch-api #javascript-tips #javascript