electron-userland / electron-json-storage

:package: Easily write and read user settings in Electron apps
1.44k stars 80 forks source link

get(key, callback) #65

Closed shaneing closed 7 years ago

shaneing commented 7 years ago
getData(key) {
  let d;
  this.storage.get(key, (error, data) => {
    if (error) {
      err(`AutoComplete::getData(key) - Error for getting ${key}`);
    }
    d = data;
  });
  return d;
}

the content of storage file:

{}

But, an error occurred

jviotti commented 7 years ago

I believe you figured it out already, but .get() is an async function, and therefore your getData function will return before that completes.