Skip to content

Not a Valid JSON file when suing get method. #9

@alexiusacademia

Description

@alexiusacademia

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions