node js fulfillmentHandler0 undefined with promises

时间:2017-05-25 04:35:34

标签: javascript node.js amazon-s3 bluebird

我有一个执行以下操作的功能:

function getUrl(id) {
    let params;
    return attModel.getById(id)
      .then(resData => {
        const attachmentMetaData = resData.shift();
        params = {
           Bucket: 'some-bucket',
           Key: [
             attachmentMetaData.fieldA,
             attachmentMetaData.fieldB,
             attachmentMetaData.fieldC
           ]
        };
        return isEnabled(attachmentMetaData.fieldD);
  })
  .then(isEnabled => {
    if (isEnabled) params.Key[1] = '0';
    params.Key = `${params.Key.join('/')}.png`;
    return params;
  })
  .then(params => { return s3.getSignedUrl('getObject', params); });
}

当我从控制器调用此函数时,以及console.log结果,我得到以下内容:

Promise {
  _bitField: 0,
  _fulfillmentHandler0: undefined,
  _rejectionHandler0: undefined,
  _promise0: undefined,
  _receiver0: undefined,
  _trace: 'some traces ...'
}

我已按照Promise fulfillment handler undefined的建议尝试附加.then,但仍会得到相同的结果。

0 个答案:

没有答案