twitchtv / igdb-api-node

Nodejs Wrapper for IGDB.com API. Requires an API key. Get one at:
https://api.igdb.com/
MIT License
128 stars 15 forks source link

Enabling CORS in React client #39

Closed jcamato closed 4 years ago

jcamato commented 4 years ago

I'm attempted to use this wrapper to fetch games, but I'm being blocked by CORS policy. After reading through the IGDB CORS documentation, I'm struggling to figure out if it's possible to call IGDB through React without setting up a server. Is there a way to modify the code below (this repo's example) to enable CORS and allow this call?

const getGames = async () => {
  const response = await igdb(APP_KEY)
    .fields(
      "id, name, rating, rating_count, popularity, cover.url, summary, release_dates.y, category"
    ) 
    .limit(20) 
    .sort("rating", "desc")
    .where("rating > 0 & rating_count >= 200 & category = 0")
   .request("/games"); 
  console.log(response.data);
};

Thank you for your time.

krazyjakee commented 4 years ago

CORS is not supported at this time: https://api-docs.igdb.com/#cors-for-js--ionic

xavdid commented 4 years ago

@krazyjakee is support planned at this time? No worries either way, just curious. I found this changelog that made it sound like it had been released (though the site looks pretty out of date).

Also, the changelog in the header at https://api.igdb.com/ links to https://igdb.github.io/api/changelog/, which is a 404.