scrimba
JSC19
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

AboutCommentsNotes
JSC19
Expand for more info
index.js
run
preview
console
const btn = document.getElementById("btn")
const foodHolder = document.getElementById("foodHolder")
btn.addEventListener("click", findYum)

async function findYum() {
try{
const response = await fetch("https://foodish-api.herokuapp.com/api/images/pizza")
const data = await response.json()
const img = document.createElement("img")
img.src = data.image
foodHolder.appendChild(img)
}
catch{
alert("Error. Try again!")
}
}

/* Task:
Call the Foodish API (https://foodish-api.herokuapp.com/) and display random images of desserts on the click of a button.

Specific URL to get a random dessert image:
https://foodish-api.herokuapp.com/api/images/dessert

Stretch goals:
- Show multiple desserts.
- Add the functionality to go back to the previous image.
*/

Console
/index.html
LIVE