简体   繁体   中英

Large Integer rounds when returned from npm request package

I am using npm package request https://www.npmjs.com/package/request to call Twitter API as follows:

request({ url: `https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=${screenName}&${countQuery}&tweet_mode=extended`,
    method: "GET",
     headers: {
       "Authorization": auth
     },
     json: true
}, function (error, response, tweets) {
     if (response.statusCode == 200) {
         console.log(tweets)
     } 
   }
})

The problem I am having is that in the returned tweets object, the id of the tweet that is for example as follows:

"created_at": "Wed May 15 19:14:49 +0000 2019",
"id": 1128740534372184064,
"id_str": "1128740534372184064",

rounds to 1128740534372184000.

When I call the Twitter API with Postman, I see the correct (above) results, but looking at body of request I see the rounded integer number. How can I fix this?

Could this be a Javascript issue? Use id_str instead. https://developer.twitter.com/en/docs/basics/twitter-ids.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM