0

I want to access 'newEtag' variable value out of the scope of 'tap.on()' callback. I have tried it but it gives 'undefined'.

    const gzip = zlib.createGzip();
    const options = { partSize: 8 * 1024 * 1024, partCount: 4 };
    const tap = createTapStream(options);
    let newEtag;
    tap.on('finish', async () => {
      newEtag = tap.calculate();
    });
    stream.pipe(gzip).pipe(tap);
    const uniqueItem = await this.uniqueDataTable.getItem({ Etag: newEtag });
    if (uniqueItem !== undefined) {
      return {
        key,
        versionId: uniqueItem.Etag,
      };
    }
  • 1
    Does this answer your question? [How to return the response from an asynchronous call](https://stackoverflow.com/questions/14220321/how-to-return-the-response-from-an-asynchronous-call) – jonrsharpe Jul 14 '21 at 12:42
  • Not exactly. Because, what I want to do is access the value from asynchronous callback to synchronous block. I read the answers but I did not get anything. – JIGNESH PATEL Jul 15 '21 at 06:33

0 Answers0