简体   繁体   English

从npm请求包返回时的大型整数回合

[英]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: 我正在使用npm软件包请求https://www.npmjs.com/package/request来调用Twitter API,如下所示:

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: 我遇到的问题是在返回的tweets对象中, tweets的ID例如如下:

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

rounds to 1128740534372184000. 舍入为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. 当我用Postman调用Twitter API时,我看到了正确的(以上)结果,但是在request正文中,我看到了四舍五入的整数。 How can I fix this? 我怎样才能解决这个问题?

Could this be a Javascript issue? 这可能是Javascript问题吗? Use id_str instead. 使用id_str代替。 https://developer.twitter.com/en/docs/basics/twitter-ids.html https://developer.twitter.com/en/docs/basics/twitter-ids.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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