Answer the question
In order to leave comments, you need to log in
how to change json in vue cli
I'm not strong in node.js, but I decided to try to use it, so that when changing an array with objects, it all goes into a json file, that's what I came up with:
const fs = require('fs');
export default {
...
changeJSON(){
fs.readFile('todo.json','utf-8',(err,data) => {
let obj = this.todos
fs.writeFile('todo.json', JSON.stringify(obj), (err) => {
if (err)
console.log(err);
})
})
},
...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question