fs.writeFileSync and fs.inlinkSyn to a particular file not working

21 views
Skip to first unread message

Emmanuel Amodu

unread,
Jun 19, 2017, 6:18:38 PM6/19/17
to nodejs
I am trying to update a certain file with the writeFileSync  method but it is not working

"negotiate": function(menu){
if (menu) {
//this would be changed later to the appropraite request
//get url from menu
//getting task list quesions
menu = fs.readFileSync(rootPath + menu.output, 'utf8');
menu = JSON.parse(menu);
}
var userData = fs.readFileSync(this.pathToUserTable(), 'utf8');
userData = JSON.parse(userData);

userData = this.updateUserDataForNegotiate(userData, menu);
//fs.unlinkSync(this.pathToUserTable());//this not working
fs.writeFileSync(this.pathToUserTable(), JSON.stringify(userData));//this not working
fs.writeFileSync(rootPath + "/database/users/test.json", JSON.stringify(userData));//this is working
this.res.send(menu);
},

This is very weird and frustrating, I have been trying for hours to get it to work. Pls I need help.



Reply all
Reply to author
Forward
0 new messages