Skip to content

Tag: fetch-api

fetch response.text() returns pending promise

I test the fetch API with jsonplaceholder URL, but my function returns “Promise State: Pending”, and I don’t understand why : I think the problem is because of asynchronous/synchronous methods? Answer I think the problem become asynchrone/synchrone method ? Yes. You’ve (mostly) correct…

JS Fetching batch data with HTTP

My RESTful service allows batching requests. I’m trying to combine requests into one batch with help of Fetch API: However it returns an error – bad request. I suppose I may combine HTTP requests in wrong way. Is there simpler way of doing this? Where in Network Chrome Dev Tools can I see nested H…

Text response is empty when using fetch

The following code: is outputting: If I use curl: I get a token in text form back (length != 0). And if I output the response header via: I get: Why am I getting no text via fetch? Answer Remove mode: ‘no-cors’. When you use no-cors mode, you’re explicitly specifying that you want an “opaque respo…

Getting Text From Fetch Response Object

I’m using fetch to make API calls and everything works but in this particular instance I’m running into an issue because the API simply returns a string — not an object. Typically, the API returns an object and I can parse the JSON object and get what I want but in this case, I’m havin…

Retrieve data from a ReadableStream object?

How may I get information from a ReadableStream object? I am using the Fetch API and I don’t see this to be clear from the documentation. The body is being returned as a ReadableStream and I would simply like to access a property within this stream. Under Response in the browser dev tools, I appear to h…