Twitter API get tweets - returns CORS origin blocked

前端 未结 1 1141
旧时难觅i
旧时难觅i 2021-01-16 02:15

I am trying to get tweets from a hashtag. I get following erros Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.twi

1条回答
  •  心在旅途
    2021-01-16 02:28

    The reason why you are getting this error is because your making the request through the browser. Browsers don't allow cross domain requests because like @allenru mentioned in the comments below: Servers need to response according to the CORS spec so the browser can proceed with the request.

    You can learn more about it here : https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS

    The proper way to fetch tweets would be making a call to the server and have the server fetch tweets for you.

    This also seems like a buggy call.
    https://api.twitter.com/1.1/search/tweets.json?f=tweets&q=%23shruthirajoli&src=typd?get=%5Bobject+Object%5D. Its not normal to have [object + object] in requests. It seems like an object that was not stringified.

    0 讨论(0)
提交回复
热议问题