Wednesday, 24 May 2017

node js fulfillmentHandler0 undefined with promises

I have a function that does the following:

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); });
}

When I call this function from the controller, and console.log the result, I get the following:

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

I've tried attaching a .then as suggested by Promise fulfillment handler undefined, but still get the same result.



via uckc

No comments:

Post a Comment