ionic-framework
ionic-framework copied to clipboard
Error in Documentation - Storage.set
Ionic version: (check one with "x") [ ] 1.x [x] 2.x
I'm submitting a ... (check one with "x") [x] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/
Current behavior:
import { Storage } from '@ionic/storage';
export class MyApp {
constructor(storage: Storage) {
storage.set('name', 'Max');
storage.get('name').then((val) => {
console.log('Your name is', val);
})
}
}
storage.get returns Null.
Expected behavior:
import { Storage } from '@ionic/storage';
export class MyApp {
constructor(storage: Storage) {
storage.set('name', 'Max');
storage.get('name').then((val) => {
console.log('Your name is', val);
})
}
}
storage.get Returns Max
Other information: Looks like is error in documentation. Set also return promise. So correct code is:
import { Storage } from '@ionic/storage';
export class MyApp {
constructor(storage: Storage) {
storage.set('name', 'Max').then(()=>{
storage.get('name').then((val) => {
console.log('Your name is', val);
})
});
}
}
Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):
Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.12
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.45
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v6.9.1
Xcode version: Not installed
This issue was moved to driftyco/ionic-site#903