+ 2

Is it possible to edit external JSON file data by just JavaScript pure ?

( Main.js ) (File.json)

9th Sep 2019, 11:16 AM
Omar Khalil Bakhsh
Omar Khalil Bakhsh - avatar
2 Answers
+ 2
Frontend javascript is sandboxed, it cannot modified any external files. Use server script, node.js.
9th Sep 2019, 12:16 PM
CalviŐ˛
CalviŐ˛ - avatar
+ 2
You can't save in a file using client-side script, you have to use some server-side scripting like PHP, NodeJS etc. to save something in a file. For example in NodeJS you can use the fs library: // load file system package var fs = require('fs'); // to read var data = JSON.parse(fs.readFileSync('data.json').toString()); // to write fs.writeFile('data.json', JSON.stringify(data)); Hope it helps.
10th Sep 2019, 6:27 AM
Ahlin Chan
Ahlin Chan - avatar