小编use*_*704的帖子

等待的承诺仍然返回<pending>

我有一个关于人的数据对象数组。每个人员对象都包含0-n个URL,以获取其他信息(人员的来宾)。

我要处理此列表,调用每个“来宾” URL,并在原始数据集中包括来宾的名字。

上下文:这是一个AWS Lambda函数。我正在使用lambda-local本地运行。(lambda-local -l index.js -e fixtures/test_event1.json)。

我已成功使用await / async来检索初始数据集。

但是我无法获得有关来宾信息的更多电话服务。即使结果等待,它始终显示一个未决的Promise。

// index.js

const fetch = require('node-fetch');

exports.handler = async function(event){

    try {
        let registrations = await getEventRegistrations();
        console.log(registrations);

/* All good here - sample console output
[ { contactId: 43452967,
    displayName: 'aaa, bbb',
    numGuests: 0,
    guestUrls: [] },
  { contactId: 43766365,
    displayName: 'bbb, ccc',
    numGuests: 1,
    guestUrls:
     [ 'https://<URL>' ] },
  { contactId: 43766359,
    displayName: 'ccc, ddd',
    numGuests: 2,
    guestUrls:
     [ …
Run Code Online (Sandbox Code Playgroud)

javascript asynchronous node.js es6-promise

2
推荐指数
1
解决办法
117
查看次数

标签 统计

asynchronous ×1

es6-promise ×1

javascript ×1

node.js ×1