I have this error, I am trying to integrate JSZipUtils

0

I have already installed it with: npm i jszip-utils , but this error appears, it is already integrated into the index, the route is correct

  

ERROR !!!: Refused to execute script from   ' link '   because its MIME type ('text / html') is not executable, and strict MIME   type checking is enabled

function generateWordFile(req, res, next) {
    function loadFile(url, callback) {
    JSZipUtils.getBinaryContent(url, callback);
}

loadFile('/public/static/docs/template_nota_medica.docx', function(error, content) {
    if (error) {
        throw error;
    }

    var zip = new JSZip();
    zip.file('word/document.xml', content);
    var doc = new Docxtemplater().loadZip(zip);

    doc.setData({
        first_name: 'John',
        last_name: 'Doe',
        phone: '0652455478',
        description: 'New Website'
    });

    try {
      // render the document (replace all occurences of {first_name} by John, {last_name} by Doe, ...)
         doc.render();
         console.log('asdf');
    } catch (error) {

    var e = {
        message: error.message,
        name: error.name,
        stack: error.stack,
        properties: error.properties
    };

    console.log(JSON.stringify({ error: e }));
    // The error thrown here contains additional information when logged with JSON.stringify (it contains a property object).
        throw error;
    }

    console.log('rendered');
    var out = doc.getZip().generate({
            type: 'blob',
            mimeType:
            'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
    }); //Output the document using Data-URI
    saveAs(out, 'output.docx');
    });
}
    
asked by Joaquin Hernandez 12.09.2018 в 20:08
source

0 answers