Closed bhavesh2799 closed 3 years ago
This is not related to the v2 API (you have /1.1/ in the URL) so the fields and expansions will not work. Also, Twitter’s API does not support CORS.
I recommend that you use https://twittercommunity.com for follow-up questions since this does not relate to these samples.
I am also facing CORS error how do I solve it.
Shivangi Singh @.***>, 26 Haz 2022 Paz, 18:36 tarihinde şunu yazdı:
I am also facing CORS error how do I solve it.
— Reply to this email directly, view it on GitHub https://github.com/twitterdev/Twitter-API-v2-sample-code/issues/32#issuecomment-1166566773, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYXQJTR5EP46AWUEKBR7CPDVRB2JVANCNFSM43OFJP3A . You are receiving this because you are subscribed to this thread.Message ID: @.*** com>
-- MEHMET ALİ AYHAN http://www.mehmetaliayhan.com.tr
The Twitter API does not support CORS so you will have to call it from a server-side application rather than directly from JavaScript in the browser.
The Twitter API does not support CORS so you will have to call it from a server-side application rather than directly from JavaScript in the browser.
Okay, I'll try on node thanks :)
`getTweets(){
var myHeaders = new HttpHeaders(); myHeaders.append("Authorization", "Bearer "+this.token); // myHeaders.append("Cookie", "guest_id=v1%3A161908241149107957; personalization_id=\"v1_ejJZ4HGUOXH10orpNKx4xQ==\"");
var requestOptions = { method: 'GET',
};
fetch("https://api.twitter.com/1.1/search/tweets.json?q==ECONOMICTIMES&max_results=10&tweet.fields=author_id,created_at,entities,geo,in_reply_to_user_id,lang,possibly_sensitive,referenced_tweets,source", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); } `