API call via proxy returns an empty status 200 response

Hello there! Some background: I am a front end dev wanting to make an API call to display data on an app I’m building. I know next to nothing about the backend. I have completed the challenges in the Backend APIs and Microservices section but that’s it.
I finally figured out how to get an API call working, and to get around the CORS problem during development, I have set up a proxy server on Heroku by cloning cors-anywhere.
Well now I don’t have the CORS error anymore but I am getting an empty response. This is what the response looks like as logged in the console:

Response { type: "cors", url: "https://myproxyserver.herokuapp.com/https://www.xeno-canto.org/api/2/recordings?query=hawaiian+duck", redirected: false, status: 200, ok: true, statusText: "OK", headers: Headers, body: ReadableStream, bodyUsed: false }

The particular API I am testing this with doesn’t require a key, so that’s not the issue. I also tried to make this in Postman and it works there. Any guidance? How do I get the JSON data I need?

Thank you!

Silly me! I forgot to turn the data into JSON.

//the first 'then' is what I was missing:
fetch('url-here')
.then(res => res.json())
.then(data => console.log(data))
.catch(err => console.error(err));

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.