0

I do:

 return new bluebird((resolve) => {

  bluebird.resolve()
  .tap(saveExcelFiles)
  .tap(...)
  .tap(() => {
      return getZip().then((rows) => {
        resolve(rows) // this outer bluebird helps me
        return rows;
      });
    })
  ;
  
});

How to return all data(for each tap) or just last tap in one bluebird wrap.

P.S. I need sequencing (one by one, tap by tap)

aaaaaaaaax10
  • 599
  • 2
  • 9
  • 21

1 Answers1

2

.tap explicitly means "ignore the return value", if you need the return value - use the standard .then:

.then(() => {
  return getZip().then((rows) => {
    // Nothing outer.
    return rows;
  });
});

Or more compactly:

.then(getZip); // that's it!

Also, you should return the promise chain instead of explicit construction:

return saveExcelFiles().tap(...).then(getZip);

Should suffice for the entire body of your function.

Benjamin Gruenbaum
  • 270,886
  • 87
  • 504
  • 504