chingu-voyages / v48-tier1-team-05

A dinosaur app for viewing detailed information about your favorite dinosaurs | Chingu Voyage-48 | https://chingu.io/
https://chingu-voyages.github.io/v48-tier1-team-05/
4 stars 0 forks source link

Move fetch function to top of app.js #139

Closed terrifricker closed 5 months ago

terrifricker commented 5 months ago

In trying to just fetch from the api once, I moved the fetchData() function to the top. The function renamed to createData() now fetches the dinosaurs from the api as well as creating the data needed for the Map and Diet Tools. The data is put into global variables that we can use later in app.js. The new variables are

allDinosaurs - an array of all dinosaur objects dinosaursPerCountry - an object that holds the number of dinosaurs found in each country dietData - an array that holds a diet object for each time period

As long as functions in app.js aren't called before the createData() function finishes, there aren't problems with the data not being there yet. For example onSearch() and showCountryInfo() are in eventListeners. I will need to make sure any function that needs the dietData isn't called until the fetch has occurred as well.

terrifricker commented 5 months ago

Merge conflicts between Ki's pull request #140 that creates dinosaur card backs and this pull request have been resolved.