c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
Node-js

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function. Received undefined

| | Node-js , web
I m using nodejs, I got the following error while appending a file. 
const fs = require('fs');
fs.appendFile('message.txt', 'Hello, user how are you?');


Solution:
The fs.appendFile function expecting third parameter as call back function.
const fs = require('fs');
fs.appendFile('message.txt', 'Hello, user how are you?', (err) => {
    if (err) throw err;
    console.log('The "data to append" was appended to file!');
  });