Fetching Fighters in FightCard

Ryan Locascio
Jun 28, 2021

What is fetching? Fetching is gathering data for the front-end of the application. We use the fetch() function to do this.

basic fetch

The first line of this code is using the fetch() function, inside this function wrapped in parenthesis a URL in a string will be placed to let the function know where the data is coming from. Since fetch() itself does not return the actual data, but an object that represents this data source we call the .then() method on the object. This takes in an argument that receives the response as the argument. On line 2 we have to return that response and since we are working with json datatypes we call .json() on the returned response. We now on line 3 pass in the content from the callback.

--

--