Requestjs有两种不同的语法:一种是数组,一种是对象

Requestjs has two different syntaxes: one as an array, one as an object

我正在尝试 运行 一个如下所示的脚本:

const response =  await request.getAsync(channelAPI);

  let responseData = JSON.parse(response[0].body);

然而,当我 运行 它在一台机器上工作时,而另一台机器只是 returns 作为对象的响应,我不需要 [0].

这是怎么回事?我 运行 之前遇到过同样的问题,两台机器都在寻找相同的 package.json 那么问题是什么?

假设您使用的是 Bluebird,我想问题是这样的:

http://bluebirdjs.com/docs/new-in-bluebird-3.html

Both promisification (Promise.promisify and Promise.promisifyAll) methods and Promise.fromCallback now by default ignore multiple arguments passed to the callback adapter and instead only the first argument is used to resolve the promise. The behavior in 2.x is to construct an array of the arguments and resolve the promise with it when more than one argument is passed to the callback adapter.

所以看起来您在两个环境中有不同的主要版本的 Bluebird。