How to use wix fetch to download a file for the user?

I have a FastAPI endpoint that returns a zip file on calling it using text. I have a button on my page that says “Download file” and when the button is clicked, the API is called. I want the file returned by the endpoint to be automatically downloaded to the user’s computer. Any ideas on how I could do this?

Side note: I guess if this approach is a bit impractical, I could return a base64 response from my endpoint instead of a file and then convert that base64 string into a zip file and download that to the user’s computer. I’m open to suggestions from you guys. Thanks a lot.

Second one sounds good!
This would work surely with an IMAGE, but not sure if this also works with a ZIP-File.

About Fetching and ENDPOINTS, take a look onto this post…

About Base64 → take a look here…

Good luck!