BrandonCookeDev / smashgg.js

Node.JS SDK for the Smash.gg public API.
https://www.npmjs.com/package/smashgg.js
34 stars 13 forks source link

CORs error from smashgg #36

Closed flemings closed 5 years ago

flemings commented 5 years ago

Hi, I am getting a CORs error from smash.gg itself. Do I need to add headers to the request to make it work? I tried 'mode':'no-cors'. Currently I am testing from localhost. Any help would be appreciated, thanks!

image

BrandonCookeDev commented 5 years ago

Hi! Smashgg historically never offered CORS on their version 1 API. It was a large issue, and means that you cannot use smashgg.js on the frontend.

However, another dev and I made a package just for you! https://github.com/BrandonCookeDev/smashgg-promise

This is a frontend-capable library that leverages an AWS Lambda function to pad on the CORS headers. Also try looking into their new API @ https://smashgg.zendesk.com/hc/en-us/articles/217471947-API-Access

They implemented GraphQL recently and should have handled CORS in this. Smashgg.js is undergoing an overhaul to ingest this new API and WILL have CORS capability. Please keep in mind when using smashgg-promise, and it will probably be sunset a few months after this package is updated.

flemings commented 5 years ago

Thanks! Will you guys be maintaining the same function signatures? e.g. Event.getEvent(...) Or will this a complete overhaul?

BrandonCookeDev commented 5 years ago

The general functionality of this package will not be changing with the overhaul. Everything you're interfacing with now will be there in V4; however they may be named differently as to adhere to a more consistent standard (ie. Event.getEventSets() will become Event.getSets() and etc).

There will be a section in the README added to make sure you can transition easily. But the change to V4 is still a little ways off, so I recommend using smashgg-promise until then.