my JSON file
[
{
"id": 1,
"task": "go dancing",
"status": false
},
{
"id": 2,
"task": "Walk",
"status": false
}
]
i got really stuck on my OOP, i tried to find the Property Status in my json and i want to update the property boolean tp be true from false
here is my code
static completed(input) {
const data = Model.getdAll(); // get './data.json' local host,
for (let i = 0; i < data.length; i++) {
if(data[i].id == input){
data[i].status = true
Model.writeFile(data);
return data
}
}
}
when i console.log( on that static method , it was like this
here is my writefile static method
static writeFile(data) {
return fs.writeFileSync("./data.json", JSON.stringify(data, null, 2) , 'utf8');
}
//when i console.log( on that static method , it was like this
Model { id: 4, task: 'going to gym', status: true }
when i write file inside that for loop and after the forloop the real data is not changed and that status still false
writeFileSyncreturn an error?