achievements-app / psn-api

A JavaScript library that lets you get trophy, user, and game data from the PlayStation Network.
https://psn-api.achievements.app
MIT License
263 stars 31 forks source link

cant get it to work with react js #149

Closed LS2355 closed 11 months ago

LS2355 commented 11 months ago

I can't seem to fetch any data when using react but if i just use plain vanilla JS it work great.

This one works great (vanilla JS) idk

but whenever i try to do the same thing in react i keep getting an 403 / forbidden error or an incorrect Npsso error. (the npsso is 100% correct)

Screenshot 2023-09-19 195220 idk-react

if possible can you get back to me with a possible solution. Pretty sure i'm just messing up somewhere but i cant seem to find it

thing to note: I added a proxy to the package.json file it was :localhost://8080. just in case that is useful

wescopeland commented 11 months ago

When using vanilla JS, are you making these calls client-side or server-side?

LS2355 commented 11 months ago

Client side

wescopeland commented 11 months ago

Sony themselves block client-side calls with their CORS policy. To get this working, you'll probably need to set up an API layer in Node.js that uses psn-api, then have your React front-end call those API endpoints.