1
votes

I am using axios to execute GET request to twitter search api in order to retrieve recent tweets that use a particular hashtag.

First I tested the twitter search API through postman and I see the id and id_str tweet status response property is consistently equal.

enter image description here

Now using axios the id value is changed and I don't know why. Below I posted my example axios request inside nodejs express controller function.

exports.postTestTwitter = async (req, res, next) => {
    const requestData =  {
        headers: {
            Authorization: 'Bearer FooToken'
        }
    };

    const hashTag = req.params.hashTag;
    const requestUrl = 'https://api.twitter.com/1.1/search/tweets.json?q=%23' + hashTag + '&result_type=mixed&until=2020-12-24';

    const twitterPosts =  await axios.get(requestUrl, requestData)
        .then((tweets) => {
            return tweets.data;
        });

    return res.json(twitterPosts);
};

The parsed status from the response is the following.

enter image description here

Can I rely axios won't change some other ids of integer values of other APIs other than Twitter? Why is this happening?

For now, I will be using id_str since this is the correct id of the tweets.

1

1 Answers

2
votes

I think its because axios isn't able to handle larger integer values came across this issue once saw another answer here