The new Ionic Storage we have a promise written with ‘get’ method.
// set a key/value
storage.set('name', 'Max');
// Or to get a key/value pair
storage.get('age').then((val) => {
console.log('Your age is', val);
});
Which is hard when we writing code with promises since it’s async behavior. Anybody came up with any suggestions for handling this. I thought of using new async/await. Will it be good?
Matter of opinion, but mine is “no”. async/await obscures the asynchronous nature of operations, which I find reduces code clarity. It also encourages ignoring errors.
This is exactly what I am trying to achieve.
But for I don’t know what reason, it breaks my app -> it loads with blank page only.
When I comment my method, it works again.
Here is my code: