pepega페페가 – 22-10 Jan 7

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)
2 Replies
Eva
Eva2y ago
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?
reactibot
reactibot2y ago
This thread hasn’t had any activity in 12 hours, so it’s now locked. Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1061406378968744007