Skip to content
Advertisement

Tag: fetch-api

How to handle streaming data using fetch?

I have used async for with great success in handling output streams from processes with node.js, but I’m struggling to get something that I was hoping could “just work” with the browser fetch API. This works great to async’ly handle chunks of output streaming from a process: (in an async function context here of course) I tried to do something

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 chrome and firefox throws a

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. System Browser: Firefox 74.0

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 server side. Answer The issue

Advertisement