Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70434

Storage: get function returns object but object-method cannot be called

$
0
0

@refle wrote:

Hi,
I have a storage set up

import { Storage } from '@ionic/storage';
export class HomePage {
...
constructor(private storage: Storage, ...){...}
  set_fun(foo){
      this.storage.set(`test`, foo);
  }
}

The foo object, which has a method “get_name()” is stored, but when I try in another page to call

this.storage.get('test').then((val) => {
        this.testvar = val.get_name();
    });

I get the error:
Uncaught (in promise). Type Error. val.get_name() is not a function

Obviously the get function does not know that val is a foo-type object. How do I deal with that?

(Using ionic 3)

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70434

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>