question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

storage.get multiple keys

See original GitHub issue

Would be nice to have a get for multiple keys like in NG2-Translate

this.storage.get(['someKey', 'anotherKey'])
  .then((data) => {
    console.log(`${data.someKey}, ${data.anotherKey}`)
  })

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

19reactions
NoNameProvidedcommented, May 27, 2017

This can be easily implemented in userland:

getMultiple(keys: string[]) {
  const promises = [];

  keys.forEach( key => promises.push(this.storage.get(key)) );

  return Promise.all(promises).then( values => {
    const result = {};
    
    values.map( (value, index) => { 
      result[keys[index]] = value; 
    });

    return result;
  });
}
3reactions
capcom-rcommented, Apr 13, 2017

I accomplished it like this:

    this.storage.forEach( (value, key, index) => {
      if (key == 'token') { this.token = value }
      // Search for whatever you're looking for using if/else statements
    }).then(() => {
      // Do your thing
    });
Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting multiple key values from Ionic2 storage
I used Promise.all for this purpose. Promise.all([this.storage.get("email"), this.storage.get("username")]).then(values ...
Read more >
Storage.key() - Web APIs - MDN Web Docs
The key() method of the Storage interface, when passed a number n, returns the name of the nth key in a given Storage...
Read more >
Get multiple values at same time using Ionic Storage
Hello, I used Ionic Storage. I saved this data: this.storage.set('key1', 'value1'); this.storage.set('key2', 'value2'); How I can get all ...
Read more >
how to access multiple keys from chrome extension's ...
I have 2 input textbox for username and password. And one picklist for some value. Now I want a user to add these...
Read more >
How to Get HTML5 Local Storage Keys with JavaScript?
Another way to get all the keys of the items stored in local storage is to use the localStorage.key method. We can use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found