0

I hope to parse data from a public endpoint: https://feeds.citibikenyc.com/stations/stations.json

Went I visit this URL, it populates data. When attempt to fetch in jsfiddle, I get a 200 "OK" status, but no data.

fetch("https://feeds.citibikenyc.com/stations/stations.json", { mode: "no-cors" })
  .then(response => {
    if (response.ok) {
      response.json().then(data => {
        console.log(data);
      });
    } else console.log('Error');
  })
  .catch(error =>
    console.log(error)
  );

https://jsfiddle.net/o60k1wgb/

I don't appear to getting errors from the endpoint, so perhaps my fetch code is incorrect?

  • You simply have a CORS issue, just setting no-cors does not mean the external API has to send you whatever you ask it to, execute your code directly on the URL you call and you see that it works. – exside May 16 '22 at 16:31

0 Answers0