简体   繁体   中英

Promise returns fulfilled promise instead of just the data

I've been trying to unzip files - which works great. I get them in an array of JsZip's own zip object .

This has a method called async with retrieves the data in the desired format - in my case blob. Works great, but instead of returning the data for each file it returns the fulfilled promise:

const urls = Object.entries(zipped.files).map(([, v]: any) => v.async('blob').then((b: any) => b).catch((err: Error) => console.error(err)));

Why?

在此处输入图片说明

I had an array of Promises that had to be called - documentation of JSZip was a bit fuzzy.

await Promises.all(promises) resolved it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM