I’m a newbie to p5.js but I’ve been playing around with using API’s. Whenever I call an API using the function loadJSON(), no matter what I always get the same error message that reads:
p5.js says: It looks like there was a problem loading your JSON file. Try checking if the file path (https://api.open-notify.org/astros.json) is correct, hosting the file online, or running a local server. (More info at Local server · processing/p5.js Wiki · GitHub)
I made sure to type the URL for the API with my key but it never works, even for an API that doesn’t require a key. So something like this:
function setup() {
// createCanvas(400, 400);
loadJSON("https://api.open-notify.org/astros.json", gotData, 'jsonp');
}
function gotData(data) {
console.log(data);
}
function draw() {
//background(220);
}
Doesn’t print, or in this case logs the array. Any ideas??