xxxxxxxxxx
46
let spaceData;
// response => response.json()
// function readResponse(response) {
// return response.json();
// }
// function logJSON(json) {
// spaceData = json;
// }
async function getSpaceData() {
let response = await fetch('astros.json');
spaceData = await response.json();
}
function setup() {
createCanvas(400, 400);
// loadJSON('astros.json', gotData);
// fetch('astros.json')
// .then(response => response.json())
// .then(json => spaceData = json);
getSpaceData();
console.log(spaceData);
}
function draw() {
background(220);
if (spaceData) {
ellipse(200, 200, spaceData.number * 100);
} else {
// loading animation
background(0, 255, 0);
}
}