xxxxxxxxxx
25
let advice; //variable for json object
//use the preload function to load the json into the variable
function preload(){
advice = loadJSON("https://api.adviceslip.com/advice")
}
//the setup function runs one time
function setup() {
createCanvas(400, 400) // create the canvas space
noLoop();
}
//this draw function will only draw once because I have noLoop() in the setup function
function draw() {
background('white') //canvas background color
fill('gold')
rect(0,100,width,200) //advice area
textSize(20);
textWrap(WORD);
textFont('Georgia');
fill('black')
text(advice.slip.advice,20,125,width-20,200) //place advice on to screen using the text function
}