Create an abortable API using AbortController and AbortSignal

Spencer Feng
2 min readJul 25, 2022

Recently I worked on a project that required me to build a typeahead search UI component. The most important feature of this search component is that it should allow the user to abort an unfinished search request at any time. If the search request is an HTTP request to the server to get the search results, I could have used the fetch API with AbortController to achieve this. However, there is not an HTTP endpoint to use. Instead, I get a wrapped API service.

--

--