loadJSON() function error message

Hi,

I tested this on the p5 web editor.

If you look at the console output by pressing F12, this is the error message on Firefox :

https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors/CORSDidNotSucceed

What is strange is that they say that it is not related to CORS policy and it works when putting the single link in a new browser tab…

I also tested this on a separate html file :

const request = new XMLHttpRequest();

request.open('GET', "http://api.open-notify.org/astros.json");
request.responseType = 'json';
request.send();

request.onload = function() {
  console.log(request.response);
}

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.open-notify.org/astros.json. (Reason: CORS request did not succeed).

I don’t understand why some public API doesn’t support CORS because otherwise no one can make request to their API from a browser…

It doesn’t work so I would contact the author of the API :wink:

Another link that can help you to understand the issue :

https://github.com/processing/p5.js/issues/1451