D
D
Denis11112018-07-13 23:48:08
JavaScript
Denis1111, 2018-07-13 23:48:08

Error in Node.js callback must be a function?

When calling this code in Node.js, an error occurs saying
TypeError [ERR_INVALID_CALLBACK] : Callback must be a function
, etc.
I don't understand what's the matter.

var fs  = require('fs');
const format = require('node.date-time');

function logTime() {
  return new Date().format('y-M-d H:M:S')+" ";
}

fs.appendFile('readme.log', logTime() + 'myText' + '\n');

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SagePtr, 2018-07-14
@Denis1111

The third parameter of the fs.appendFile function is to specify the function that will be called when the given function is executed. You can put an empty anonymous function there: function(){}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question