Fetch with promises
async function start() {
try {
fetch("https://dog.ceo/api/breeds/list/all").then(function(response) {
return response.json()
}).then(function(data) {
createBreedList(data.message)
})
} catch (e) {
console.log("There was a problem fetching the breed list.")
}
}
Fetch with
async
&
await
keywords
async function start() {
try {
const response = await fetch("https://dog.ceo/api/breeds/list/all")
const data = await response.json()
createBreedList(data.message)
} catch (e) {
console.log("There was a problem fetching the breed list.")
}
}