CopyPastor

Detecting plagiarism made easy.

Score: 0.7505939602851868; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2019-04-17
by ORBIT

Original Post

Original - Posted on 2019-04-17
by María Cristina Fernández López



            
Present in both answers; Present only in the new answer; Present only in the old answer;

plsease refer [this][1]

import { NativeStorage } from '@ionic-native/native-storage/ngx'; constructor(private nativeStorage: NativeStorage) { }
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
import { NativeStorage } from '@ionic-native/native-storage/ngx';
constructor(private nativeStorage: NativeStorage) { } this.nativeStorage.setItem('myitem', {property: 'value', anotherProperty: 'anotherValue'}) .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) );
<!-- end snippet -->
this.nativeStorage.setItem('myitem', {property: 'value', anotherProperty: 'anotherValue'}) .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) );

[1]: https://ionicframework.com/docs/native/native-storage
it seems that you get the error in this funtion // get a key/value pair getValue(key: string) { this.storage.get(key).then((val) => { console.log('get ' + key + ' ', val); this.data[key] = ""; this.data[key] = val; }).catch((error) => { console.log('get error for ' + key + '', error); }); }
when you try to get stoker key returns a null reference and then the error. Maybe there is not item stored for this key or the palform was not ready when you call the storage.
When you work arround the storage you shoud wait from the platform to be ready like this:
import { Platform } from '@ionic/angular'; import { NativeStorage } from '@ionic-native/native-storage/ngx';
-----
constructor(private storage: NativeStorage, private plt: Platform) {}
this.plt.ready().then(() => { // call native storage });
And think is better use Native Storage than ionic storage.
Hope this help you.


        
Present in both answers; Present only in the new answer; Present only in the old answer;