I am attempting to use the Mammoth Node.js package to convert a file from Docx to HTML. The Mammoth Readme suggests the following format for converting the file:
var mammoth = require("mammoth");
mammoth.convertToHtml({path: "path/to/document.docx"})
.then(function(result){
var html = result.value; // The generated HTML
var messages = result.messages; // Any messages, such as warnings during conversion
})
.done();
I have placed this template code within a convertDoc
function and I am attempting to use the value of html
elsewhere in the code after calling the convertDoc
function.
Placing a return html
statement anywhere within the convertDoc
function will not allow me to use the stored html, however I can output the correct html contents to console. I need advice on how to return/make use of the html variable from outside the promise, thanks.