I manage to solve all of the problems i encountered on my own, by reading reference page, googling, by watching yt tutorials… but i have problem with loading JSON with url which is not working even thought I done everything by the book…
Here is the code, the simplest possible - and it’s not working:
function setup() {
var url = 'http://api.open-notify.org/iss-now.json';
loadJSON(url, gotData, 'jsonp');
}
function gotData (data) {
print (data.iss_position.latitude);
}
It’s not working with or without “jsonp” argument.
If i put the json content in local file called iss.json, than it’s working.
function setup() {
// createCanvas (600,400);
var url = 'iss.json';
loadJSON(url, gotData);
}
function gotData (data) {
print (data.iss_position.latitude);
}
The same is with open weather API, it’s not retrieving the data.
But earthquake.usgs.gov from reference loadJSON example is working just fine…
Hi! I can open the json in browser without a problem. I now figured out use of console (i use p5.js web editor)… so i find out that i am getting errors:
Mixed Content: The page at 'https://editor.p5js.org/Ivanko/sketches/rJ7nG9R6X' was loaded over HTTPS, but requested an insecure resource 'http://api.open-notify.org/iss-now.json'. This request has been blocked; the content must be served over HTTPS.
VM111 about:srcdoc:1 Uncaught (in promise) TypeError: Failed to fetch
VM111 about:srcdoc:1 Uncaught (in promise) TypeError: Failed to fetch
Regarding the first error, if i put https://api.open-notify.org/iss-now.json in browser, with https not with http, i get blank page, so i must use http in url, but why am i getting that error then.
And for the second… well, googling doesn’t really help with my limited knowledge