xxxxxxxxxx
32
let woof;
function setup() {
createCanvas(400, 400);
textAlign(CENTER);
stroke(255);
fill(255);
textSize(30);
}
function draw() {
background(0);
if(woof){
image(woof, 0, 0, width, height);
} else {
text('Fetch a dog 🐶', width/2, height/2);
}
}
async function getDog() {
let url = "https://dog.ceo/api/breeds/image/random";
let response = await fetch(url);
let data = await response.json();
woof = loadImage(data.message);
}
function mousePressed() {
getDog();
}