Skip to content

Tag: fetch-api

Fetch API: how to determine if an error is a network error

So I have some code like this: Where transform can throw some of its own errors. I’m try to catch for network errors from the fetch API. My question is how do I implement isNetworkError that works across browsers? Note: that this should only return true if the network is offline. It seems like both chro…

Javascript Fetch is Slow (60ms vs 3ms)

Running Javascript fetch takes about 60ms per call on my machine. Compared to Python requests at 3ms, this is much slower. Questions Why is fetch so much slower? Is there any way to speed it up? I am OK with answers that require me to reconfigure my browser. Experiment These are the details of my experiment. …

Empty body in fetch POST request

I’m struggling with the fetch API in Javascript. When I try to POST something to my server with fetch method, the request body contains an empty array. But when I use Postman it works. Here is my server-side code in Node.js: Here is my client-side code: The problem is that the req.body is empty on serve…