Skip to content

Tag: fetch-api

CORS error, but data is fetched regardless

I have a generated React site I am hosting in an S3 bucket. One of my components attempts to fetch something when loaded: The url I am fetching is an AWS API Gateway. I have enabled CORS there, via the dropdown, with no changes to the default configuration. In my console, for both the remote site and locally during development,

fetch() unexpected end of input

I am using fetch() to grab data from api server. My error looks like this: Can you please tell me what am I doing wrong. Answer Opaque Responses A response for a no-cors request to a cross-origin resource has a response type of ‘opaque’. If you log the response before trying to turn it to JSON, you will see a

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 having trouble finding the text I’m

Accessing object in returned promise using fetch w/ react js

I have this function: Which returns this in the console: Promise {[[PromiseStatus]]: “pending”, [[PromiseValue]]: undefined} proto [[PromiseStatus]] : “resolved” I need to access the name/value pairs in the object but I can’t get to them. I’m assuming I need to take one extra step after I convert the response to json but can’t figure it out. If anyone could help