1

i am trying to connect twitter API of getting friends (followers) of user via twitter's api with endpoint that mentioned here

https://api.twitter.com/1.1/friends/list.json

Error that i am getting is that about cors, though i have manage it from browser side

Here is my code that i use for fetch user

const response = await fetch('https://api.twitter.com/1.1/friends/list.json',{
            method: 'GET',
            headers : {
                "Content-Type": "application/json;charset=UTF-8",
                'Authorization' : 'Bearer my_token'
            }
        })

1 Answers1

1

The Twitter API does not support CORS and you cannot call it in a browser in this manner. You will need to use server-side code.

(additionally, the v1.1 API you are trying to use is a legacy API and you would be better to look at v2 - the equivalent is the Follows lookup functionality)

Andy Piper
  • 11,422
  • 2
  • 26
  • 49