R
Reactiflux

help-js

pepega페페가 – 22-10 Jan 7

Ppepega페페가1/7/2023
Hi, I have a problem with JSZip library. it downloads an empty zip... I think I know whats the issue but dunno how to fix.. The generateAsync function is called immediately on the function call for some reason and hence it doesnt add any files to it. Why is zip.generateasync being called before the loop is over? How to wait for it to finish adding files to zip object and then call it? (I am fetching mp4 videos from URL's and trying to save them in a zip file and download it afterwards)
EEva1/7/2023
Why is zip.generateasync being called before the loop is over?
You don't await fetch, nor .arrayBuffer() call, they just run in background while generateAsync is already invoked You can pretty much just add return fetch(...) and result result.arrayBuffer and it should await whole promise chain or use await, ditching all the .thens for less nesting and IMO easier to read code?
UUUnknown User1/8/2023
Message Not Public
Sign In & Join Server To View

Looking for more? Join the community!