0👍
The Response object, in turn, does not directly contain the actual JSON response body but is instead a representation of the entire HTTP response. So, to extract the JSON body content from the Response object, we use the json() method, which returns a second promise that resolves with the result of parsing the response body text as JSON.
In summary, to get your JSON, use json()
method on the returned fetch response
const response = await fetch('https://ksjkfsjdbnfksjfksjf744.netlify.app/.netlify/functions/api/demo',
{ mode: 'no-cors' })
const responseObject = await response.json()
console.log(responseObject)
Edit:
This will only work if mode: 'no-cors'
is removed. Reasoning is here. Instead of trying to bypass CORS, the better solution is to add the frontend’s origin to be allowed by CORS on the backend.
Source:stackexchange.com