How to fire the final console.log AFTER the callback is finished.
JavaScript
x
15
15
1
var nodePandoc = require('node-pandoc');
2
var src, args;
3
4
src = 'Lesson.docx';
5
args = '-f docx -t markdown -o ./Lesson.md';
6
7
callback = function (err, result) {
8
if (err) console.error('Oh No: ',err);
9
return console.log("callback result:",result), result;
10
};
11
12
nodePandoc(src, args, callback);
13
14
console.log("Conversion finished, you can call function to move the file around");
15
Advertisement
Answer
The easiest way is to just log the final line from within the callback:
JavaScript
1
14
14
1
var nodePandoc = require('node-pandoc');
2
var src, args;
3
4
src = 'Lesson.docx';
5
args = '-f docx -t markdown -o ./Lesson.md';
6
7
callback = function (err, result) {
8
if (err) return console.error('Oh No: ',err);
9
console.log("callback result:",result);
10
console.log("Conversion finished, you can call function to move the file around");
11
};
12
13
nodePandoc(src, args, callback);
14