Search
fetch with Timeout
16.1.2023
A few years back I wrote a blog post about how write a fetch Promise that times out. The function was effective but the code wasn’t great, mostly because AbortController , which allows you to cancel a fetch Promise, did not yet exist. With AbortController and AbortSignal available...
How to Cancel Pending API Requests to Show Correct Data
25.6.2021
I recently had to create a widget in React that fetches data from multiple API endpoints. As the user clicks around, new data is fetched and marshalled into the UI. But it caused some problems.
One problem quickly became evident: …
The post How to Cancel Pending API Requests to Show Correct...
Using AbortController as an Alternative for Removing Event Listeners
15.2.2021
The idea of an “abortable” fetch came to life in 2017 when AbortController was released. That gives us a way to bail on an API request initiated by fetch() — even multiple calls — whenever we want.
Here’s a super …
The post Using AbortController as an Alternative for Removing Event Listeners...
How to Cancel a Fetch Request
17.3.2020
JavaScript promises have always been a major win for the language — they’ve led to a revolution of asynchronous coding that has vastly improved performance on the web. One shortcoming of native promises is that there’s no true way to cancel a fetch…until now. A...