React 18 question about use of static genre data

The static data I get from the network tab for genres is correct but every genre object also contains an array of all the games in that genre. I’ve double and triple checked that the request url is correct and the API docs show the endpoint as only returning the list of genres. It still works but is a lot of unnecessary data. My genres.ts file is almost 900 lines. I could manually delete the games array from every genre object but according to the docs I shouldn’t be seeing games in this list.

I was thinking of doing something like checking in the background for genre list updates so the list could refresh in the case where a new genre is added. But I wanted to get this problem straightened out first before tackling something like that.

Any ideas?

If this is the case, then the best course of action would be to reach out to the API provider and report the issue to them. It’s possible that there was a mistake in the documentation or that the API has changed since the documentation was written. By reporting the issue, the API provider can investigate and update the documentation and/or fix the API to ensure that it only returns the expected data.

In the meantime, if you want to remove the games array from each genre object, you can do so in your code by iterating through the array of genres and deleting the games array from each genre object. However, keep in mind that this is a temporary workaround and may not be necessary if the API provider fixes the issue.

As for checking in the background for genre list updates, that’s a good idea if the API provider supports it. You can use tools like polling or webhooks to periodically check for updates and update your application accordingly. However, this is a separate issue from the unexpected data being returned by the API, and you should address that issue first.

1 Like