sppo works right but, spid doesn’t
I think they have same structure so, I can’t understand.
Here is the structure of spid
function setup() {
createCanvas(300, 300);
sppo = loadJSON("../jsons/spposition.json");
spid = loadJSON("https://static.api.nexon.co.kr/fifaonline4/latest/spid.json");
}
function draw() {
background(255);
fill(0);
text(sppo[0]["desc"],20,20);
text(spid[3]["name"],20,60);
}
Are you seeing any errors in the console in your browser?
Sven
June 6, 2020, 2:33pm
3
loadJSON
is asynchronous, meaning it may not have finished when draw
is called. The documentation for loadJSON
shows how to handle that using a callback function or by fetching the JSON file inside the preload
function.
1 Like
I didn’t think about checking the console because it was my first time programming.
There are many messages.
on atom-live-server sppo works and spid doesn’t. But, on github io both don’t work.
Thanks, now I use preload function but it still doesn’t work