saveAs module doesn't work

First, thanks to Wix guys: I asked to ass saveAs and docx modules and they did!

Now I have problem, the saveAs module doesn’t work.


import {saveAs} from ‘file-saver’ ;
import Blob from ‘blob’ ;

export function button1_click (event) {
var b = new Blob([ “Hello, world!” ], {type: “text/plain;charset=utf-8” });
saveAs(b, “hello world.txt” );
console.log(b);
}


The blob is been created as I see at the console, but it doesn’t saved and no error or warning message.

Please help, thank you

I got an email alert that Gal Carmi answers my post but I can’t see it here :no_mouth: Can someone help me please?

I got a workaround for you,

insert the logic inside an iframe and it should work (worked for me).
I imported the external js file from cdn site.
if you want to do it more professionally store the js file inside your backend and then expose it with http function (read the js file with nodejs readFileSync from fs native library) and then fetch it from your frontend instead of from a cdn site.

my html code:

<!DOCTYPE html>
<html lang="en">
 <head>
 <meta charset="UTF-8" />
 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
 <meta http-equiv="X-UA-Compatible" content="ie=edge" />
 <title>Document</title>
 <script src="https://cdn.jsdelivr.net/npm/file-saver@2.0.2/dist/FileSaver.js"></script>
 </head>
 <body>
 <script>
 var blob = new Blob(["Hello, world!"], {
 type: "text/plain;charset=utf-8",
      });
 saveAs(blob, "hello world.txt");
 </script>
 </body>
</html>


Thank you, Gal! I know I can use iFrame, but I wanted to avoid it. My mission is to create a word document (that is why I asked the docx module) and I’d like to use the corvid ide, not to write code to the iframe (it is going to be a very long code to generate the docx). That’s why I hoped the saveAs works.

You have suggested the professional way of storing a file etc, which I admit I didn’t understand (as I mentioned, I hardly know js) but I will want to try if you can tell me that in this way I can use only corvid ide? I hope I’m understood…

unfortunately, you can’t use corvid ide with this npm.
currently it is a problem to use frontend npm’s inside corvid, because most of the time they use window object. in corvid you don’t have access to such an object.

I see… so is there any chance that you guys can fix the saveAs problem?
Please?