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.")
  }
}
by Valeri Tandilashvili
3 years ago
JavaScript
The 10 Days of JavaScript
0
Pro tip: use ```triple backticks around text``` to write in code fences