Skip to main content

Day 21 - Fetching and Using API Data

Morning Javascript: Sort

  • Docs
  • This method sorts elements in an array.
    • With this you can add functionality to sort a list of information by different parameters at the click of a button

Activity

  1. Sort an array of numbers
    • Create an array of numbers
    • use sort syntax to order them from lowest to highest
  2. Sort strings alphabetically
    • Add a bunch of words to an array,
    • Sort it and return an arranged array to a new variable

Routing

  • Docs
  • Access the nuxt 3 router with useRoute()
    • ex: const route = useRoute() on a page will give that page access to all it’s routing information
    • this gives access to route params
  • This can save you a lot of time depending on how your routes are structured. You can call the router for navigation information
  • Learn a bit about how Nuxt 3 routes pages in order to make the most of dynamic route generation

Fetching Data

  • Video
  • useFetch() Composable
    • syntax to fetch from an api: const { data: category } = await useFetch('https://location-to-api-data/')
    • then you can access variables with whatever term that you put in place of “category”

Group Project Setup and Prep Session

  • Break out into groups
  • Brainstorm session
  • Q&A
  • Project Planning in Teams