I've been on a wild goose chase trying to solve this puzzling issue.
RAWG has transitioned to using their own API instead of Rapid API for game reviews, and I'm in need of data for "Tom Clancy Rainbow Six Siege".
Despite my efforts to convert the response data from the request into a response.json using the code provided, I'm unable to retrieve information about the game "Tom Clancy Rainbow Six Siege".
fetch("https://api.rawg.io/api/games?key=[KEY]&developers=ubisoft", {
method: 'GET'
})
// Fetches the response from the website
.then(response => response.json())
// Utilizes the data in the json to populate the website with relevant details
.then(data => {
console.log(data);
for (const game in data.results) {
if (game == 6) {
console.log(game[0]['id']);
}
}
});
The returned API data (as shown in console.log):
{count: 305, next: 'https://api.rawg.io/api/games?developers=ubisoft&key=[key]&page=2', previous: null, results: Array(20), user_platforms: false}
count: 305
next: "https://api.rawg.io/api/games?developers=ubisoft&key=[key]&page=2"
previous: null
results: Array(20)
... (other game entries omitted for brevity)
7:
added: 5061
... (more details about Rainbow six siege)
[[Prototype]]: Object
My struggle lies in accessing #7 (Rainbow six siege) to retrieve the id and name. Unfortunately, the for
loop only returns the number 6
, leaving me stumped without access to any further data.