toddrob99 / MLB-StatsAPI

Python wrapper for MLB Stats API
GNU General Public License v3.0
533 stars 100 forks source link

Issue making client side request to api #89

Closed maxnbf closed 2 years ago

maxnbf commented 2 years ago

Im trying to make an axios request on the client side of a react web app and im receiving this error.

Access to XMLHttpRequest at 'https://statsapi.mlb.com/api/v1/schedule?sportId=1&teamId=110&opponentId=108&season=2019' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Was curious if youve ever come across this when working with the MLB api. Most of the solutions ive found online i dont really understand so just asking here since you seem to be an expert with this API. If this is out of your depth, I understand. Thanks!

toddrob99 commented 2 years ago

I am not familiar with react, but I found this when searching for your error: https://stackoverflow.com/questions/41497674/access-control-allow-origin-issue-when-api-call-made-from-react-isomorphic-ap. One of the comments links to this question: https://stackoverflow.com/questions/51701630/typeerror-networkerror-when-attempting-to-fetch-resource. Since I don't know much about react I don't fully understand the solution, but hopefully those will help you. If not, I would suggest asking for help in a react-specific forum.

toddrob99 commented 2 years ago

Closing since this is a react issue and not related to this package