如何在节点回调后执行操作?
How to do an action after callback in node?
如何在回调完成后触发最终 console.log。
var nodePandoc = require('node-pandoc');
var src, args;
src = 'Lesson.docx';
args = '-f docx -t markdown -o ./Lesson.md';
callback = function (err, result) {
if (err) console.error('Oh No: ',err);
return console.log("callback result:",result), result;
};
nodePandoc(src, args, callback);
console.log("Conversion finished, you can call function to move the file around");
最简单的方法是只记录回调中的最后一行:
var nodePandoc = require('node-pandoc');
var src, args;
src = 'Lesson.docx';
args = '-f docx -t markdown -o ./Lesson.md';
callback = function (err, result) {
if (err) return console.error('Oh No: ',err);
console.log("callback result:",result);
console.log("Conversion finished, you can call function to move the file around");
};
nodePandoc(src, args, callback);
如何在回调完成后触发最终 console.log。
var nodePandoc = require('node-pandoc');
var src, args;
src = 'Lesson.docx';
args = '-f docx -t markdown -o ./Lesson.md';
callback = function (err, result) {
if (err) console.error('Oh No: ',err);
return console.log("callback result:",result), result;
};
nodePandoc(src, args, callback);
console.log("Conversion finished, you can call function to move the file around");
最简单的方法是只记录回调中的最后一行:
var nodePandoc = require('node-pandoc');
var src, args;
src = 'Lesson.docx';
args = '-f docx -t markdown -o ./Lesson.md';
callback = function (err, result) {
if (err) return console.error('Oh No: ',err);
console.log("callback result:",result);
console.log("Conversion finished, you can call function to move the file around");
};
nodePandoc(src, args, callback);