Answer the question
In order to leave comments, you need to log in
How to handle the Successful save event in fs.promises.writeFile?
I want to asynchronously write data to a file and when the file is written, handle this event.
I looked at the documentation ( https://nodejs.org/api/fs.html#fs_fs_writefile_fil...
FSP.writeFile(dir_task + '/mapdata.json', JSON.stringify(mapdata), 'utf8', (err) => {
Log('1234');
if (err) throw err;
Log('1234676');
task.stat.is_end = true;
});
Answer the question
In order to leave comments, you need to log in
Promises do not have a callback, but the then
FSP.writeFile(....).then(okHandler, errorHandler);
https://learn.javascript.ru/promise-basics
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question