Make a call to the URL below, pass the JSON it returns to a function and inside that function loop through the results and log each game's name.
In the catch method of your code, redirect to error.html if there is an error.
https://api.rawg.io/api/games?genres=sports
This is a question I'm trying to solve. I have this as of yet but have gotten stuck. I'm unsure as to how I should loop the JSON in a function to get only the names as the assignment asks for.
Because 'fetch' is built on promises, and a successfull call will be handled by a 'then' method, is 'data' the function argument? which means I have the function already?
const Url = `https://api.rawg.io/api/games?genres=sports`;
fetch(Url)
.then(data => {
return data.json();
})
.then(Response => {
console.log(Response);
});