T
T
tyoma_koder2021-09-21 15:07:05
Apache Cordova
tyoma_koder, 2021-09-21 15:07:05

Why is there an error in cordova-plugin-nativestorage with nativeStorage.setItem?

Installed the cordova-plugin-nativestorage plugin, in app.module.ts

import { NativeStorage } from '@ionic-native/native-storage/ngx';
@NgModule({
providers: [
    NativeStorage
  ]
})

in the ts file of the page
constructor(private nativeStorage: NativeStorage){
this.nativeStorage.setItem('myitem', 123)
      .then(
        () => console.log('Stored item!'),
        error => console.error('Error storing item', error)
      );

this.nativeStorage.getItem('myitem')
      .then(
        data => console.log(data),
        error => console.error(error)
      );
}


When running TypeError: Object(...) is not a function on the line with this.nativeStorage.setItem even though typeof this.nativeStorage.setItem returns a function

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question