Hi, I would like to know how much value there is in my local storage.

hmm… try: =>{

If you want to check whether your data exist, then:'data_key').then(your_data =>{}).catch(err=>{
console.log('Your data don't exist and returns error in catch: ' + JSON.stringify(err);

ok, thanks, good, but how to have this value in a variable ? like this :

let lengthStorage = =>{
return result.length;

not working, I know, but what is the correct syntax ?

The short answer that will save you lots of frustration is “don’t”. Only rely on it from within the then clause.

it does not work that way. if it is a ordinary function like:
let a = function my_func(){
return something;

this works. but when using ‘.then()’ you have to deal with it within the '{}'
for example: =>{
//do everything you need to do with the result

or, you can set var outside the and assign the data when you get it.
for example(inside your page.ts class:

thedata; =>{
    this.thedata = result;

*you dont ‘let’ when setting variable inside your page class. unless it is in your constructor.

1 Like