Not a Valid JSON file when suing get method.
alexiusacademia opened this issue · 3 comments
alexiusacademia commented
Hi there. I get this error on macOS.
var data = new Object();
data.name = name;
data.address = address;
storage.set('customers.json', data)
.then(() => {
console.log('Data saved successfully!')
})
.catch((err) => {
console.log(err);
});
It writes to the file but then when I use the get function,
var oldData = storage.get('customers.json')
.then(d => {
console.log(d);
})
.catch(err => {
console.log(err);
});
It gives me that the error.
And here is what the console gives:
Error: The file in path /Users/syncster31/Library/Application Support/ASMS/customers.json is not a valid json file
at /Users/syncster31/Documents/Programming/Electron/my-app/node_modules/electron-storage/dist/index…:37
at tryToString (fs.js:449)
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:436)
gregoirepuget commented
@alexiusacademia Same error.
How did you solved it ?
Thks
gregoirepuget commented
Same error on mac
alexiusacademia commented
I didn't. I wrote my own library electron-db.