var fs = require('fs')
2- Define the object to be added to the JSON filevar data = {
name: "rafael"
}
3- Use filesystem's writeFile() function to write into a custom "data.json" filefs.writeFile("./data.json", JSON.stringify(data), (err) => {
console.log("write successful", err)
})
Where: JSON.stringify function saves the data as a stringThat's it!
No comments:
Post a Comment