[英]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 .我将它们放入 JsZip 自己的zip object数组中。
This has a method called async with retrieves the data in the desired format - in my case blob.这有一个名为 async 的方法,它以所需的格式检索数据 - 在我的例子中是 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.我有一个必须调用的 Promise 数组 - JSZip 的文档有点模糊。
await Promises.all(promises)
resolved it await Promises.all(promises)
解决了它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.