IONIC Storage is null when i call storage.get(key)
Im trying to set the user info when i login into the app and when i go to the profile page im trying to retrieve the data.
To set and get the user info Im using a separate service
import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable, EventEmitter } from '@angular/core';
import {Storage} from '@ionic/storage';
@Injectable()
export class LoginService {
private loginUrl = UrlService.APIURL+'/login/';
userEvent: EventEmitter<any> = new EventEmitter();
constructor(private http: HttpClient,
private storage:Storage) { }
public setStorageUser(user:any){
return this.storage.set('user', user);
}
public getStorageUser():Promise<any>{
return this.storage.get('user');
}
}
Setting value on Login Page
this.loginService.setStorageUser(userData).then(()=>{
this.navController.setRoot(HomePage);
});
Retrieving the user data on Profile page
this.loginService.getStorageUser().then((user)=>{
console.log(JSON.stringify(user));
});
App module page on my app
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule } from '@angular/common/http';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { AppAvailability } from '@ionic-native/app-availability';
import { InAppBrowser } from '@ionic-native/in-app-browser';
import { AndroidExoplayer } from '@ionic-native/android-exoplayer';
import { IonicStorageModule } from '@ionic/storage';
import {PayPal} from '@ionic-native/paypal';
import { FileTransfer } from '@ionic-native/file-transfer';
import { File } from '@ionic-native/file';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { LoginPage } from '../pages/login/login';
import {ChannelListPage} from '../pages/channel-list/channel-list';
import {ListsPage} from '../pages/lists/lists';
import { LoginService } from '../providers/login.service';
import { UserService } from '../providers/user.service';
import { FileServiceProvider } from '../providers/file-service';
import { CategoryService } from '../providers/category.service';
import { ChannelService } from '../providers/channel.service';
import { SubscriptionService } from '../providers/subscription.service';
import {SideMenuPage} from '../pages/side-menu/side-menu';
import { CategoryPage} from '../pages/category/category';
import { ChannelsPage} from '../pages/channels/channels';
import { FavoritePage} from '../pages/favorite/favorite';
import { ChannelPage} from '../pages/channel/channel';
import { CategoryDetailPage} from '../pages/category-detail/category-detail';
import {PlayerPage} from '../pages/player/player';
import {RegisterPage} from '../pages/register/register';
import {PaymentPage} from '../pages/payment/payment';
import {ProfilePage} from '../pages/profile/profile';
@NgModule({
declarations: [
ChannelListPage,
ListsPage,
MyApp,
HomePage,
LoginPage,
SideMenuPage,
FavoritePage,
CategoryPage,
ChannelsPage,
CategoryDetailPage,
PlayerPage,
ChannelPage,
RegisterPage,
PaymentPage,
ProfilePage
],
imports: [
BrowserModule,
HttpClientModule,
IonicModule.forRoot(MyApp),
IonicStorageModule.forRoot()
],
bootstrap: [IonicApp],
entryComponents: [
ChannelListPage,
ListsPage,
MyApp,
HomePage,
LoginPage,
SideMenuPage,
CategoryPage,
ChannelsPage,
FavoritePage,
CategoryDetailPage,
PlayerPage,
ChannelPage,
RegisterPage,
PaymentPage,
ProfilePage
],
providers: [
File,
FileTransfer,
StatusBar,
SplashScreen,
AppAvailability,
AndroidExoplayer,
InAppBrowser,
{provide: ErrorHandler, useClass: IonicErrorHandler},
FileServiceProvider,
LoginService,
CategoryService,
ChannelService,
SubscriptionService,
UserService,
PayPal
]
})
export class AppModule {}
I always get null user, help!!
ionic-framework ionic-storage
|
show 4 more comments
Im trying to set the user info when i login into the app and when i go to the profile page im trying to retrieve the data.
To set and get the user info Im using a separate service
import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable, EventEmitter } from '@angular/core';
import {Storage} from '@ionic/storage';
@Injectable()
export class LoginService {
private loginUrl = UrlService.APIURL+'/login/';
userEvent: EventEmitter<any> = new EventEmitter();
constructor(private http: HttpClient,
private storage:Storage) { }
public setStorageUser(user:any){
return this.storage.set('user', user);
}
public getStorageUser():Promise<any>{
return this.storage.get('user');
}
}
Setting value on Login Page
this.loginService.setStorageUser(userData).then(()=>{
this.navController.setRoot(HomePage);
});
Retrieving the user data on Profile page
this.loginService.getStorageUser().then((user)=>{
console.log(JSON.stringify(user));
});
App module page on my app
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule } from '@angular/common/http';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { AppAvailability } from '@ionic-native/app-availability';
import { InAppBrowser } from '@ionic-native/in-app-browser';
import { AndroidExoplayer } from '@ionic-native/android-exoplayer';
import { IonicStorageModule } from '@ionic/storage';
import {PayPal} from '@ionic-native/paypal';
import { FileTransfer } from '@ionic-native/file-transfer';
import { File } from '@ionic-native/file';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { LoginPage } from '../pages/login/login';
import {ChannelListPage} from '../pages/channel-list/channel-list';
import {ListsPage} from '../pages/lists/lists';
import { LoginService } from '../providers/login.service';
import { UserService } from '../providers/user.service';
import { FileServiceProvider } from '../providers/file-service';
import { CategoryService } from '../providers/category.service';
import { ChannelService } from '../providers/channel.service';
import { SubscriptionService } from '../providers/subscription.service';
import {SideMenuPage} from '../pages/side-menu/side-menu';
import { CategoryPage} from '../pages/category/category';
import { ChannelsPage} from '../pages/channels/channels';
import { FavoritePage} from '../pages/favorite/favorite';
import { ChannelPage} from '../pages/channel/channel';
import { CategoryDetailPage} from '../pages/category-detail/category-detail';
import {PlayerPage} from '../pages/player/player';
import {RegisterPage} from '../pages/register/register';
import {PaymentPage} from '../pages/payment/payment';
import {ProfilePage} from '../pages/profile/profile';
@NgModule({
declarations: [
ChannelListPage,
ListsPage,
MyApp,
HomePage,
LoginPage,
SideMenuPage,
FavoritePage,
CategoryPage,
ChannelsPage,
CategoryDetailPage,
PlayerPage,
ChannelPage,
RegisterPage,
PaymentPage,
ProfilePage
],
imports: [
BrowserModule,
HttpClientModule,
IonicModule.forRoot(MyApp),
IonicStorageModule.forRoot()
],
bootstrap: [IonicApp],
entryComponents: [
ChannelListPage,
ListsPage,
MyApp,
HomePage,
LoginPage,
SideMenuPage,
CategoryPage,
ChannelsPage,
FavoritePage,
CategoryDetailPage,
PlayerPage,
ChannelPage,
RegisterPage,
PaymentPage,
ProfilePage
],
providers: [
File,
FileTransfer,
StatusBar,
SplashScreen,
AppAvailability,
AndroidExoplayer,
InAppBrowser,
{provide: ErrorHandler, useClass: IonicErrorHandler},
FileServiceProvider,
LoginService,
CategoryService,
ChannelService,
SubscriptionService,
UserService,
PayPal
]
})
export class AppModule {}
I always get null user, help!!
ionic-framework ionic-storage
Hi! could you show more code from your service (where you set and get user info)? Specifically: are you injecting Storage in the constructor? Are you running this code after the deviceReady event?
– Nicolás Longhi
Jan 2 at 18:49
Thanks for your early response, i update the code.
– Okyam
Jan 2 at 18:56
Everything looks fine. Could you log the value of user before attempting to save it? Like this: public setStorageUser(user:any){ console.log(user); return this.storage.set('user', user); }
– Nicolás Longhi
Jan 2 at 19:19
I already logged the value in my home page after login and i get the information of the user, but when i go to my side menu and click to the perfil option it returns null, and when i tried to log the value in app.componet.ts is like at app.componet level storage is null because my side menu is configured in my app componet, Im not sure
– Okyam
Jan 2 at 19:29
This shouldn't be a problem because Storage should have only one instance within your app. Unless you are configuring the Storage module in multiple Modules in your app. So, if I understand correctly you can retrieve the user info from storage with that same code in your home page, but not in your side menu? In this case I would need to see the declaration of each component
– Nicolás Longhi
Jan 2 at 23:11
|
show 4 more comments
Im trying to set the user info when i login into the app and when i go to the profile page im trying to retrieve the data.
To set and get the user info Im using a separate service
import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable, EventEmitter } from '@angular/core';
import {Storage} from '@ionic/storage';
@Injectable()
export class LoginService {
private loginUrl = UrlService.APIURL+'/login/';
userEvent: EventEmitter<any> = new EventEmitter();
constructor(private http: HttpClient,
private storage:Storage) { }
public setStorageUser(user:any){
return this.storage.set('user', user);
}
public getStorageUser():Promise<any>{
return this.storage.get('user');
}
}
Setting value on Login Page
this.loginService.setStorageUser(userData).then(()=>{
this.navController.setRoot(HomePage);
});
Retrieving the user data on Profile page
this.loginService.getStorageUser().then((user)=>{
console.log(JSON.stringify(user));
});
App module page on my app
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule } from '@angular/common/http';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { AppAvailability } from '@ionic-native/app-availability';
import { InAppBrowser } from '@ionic-native/in-app-browser';
import { AndroidExoplayer } from '@ionic-native/android-exoplayer';
import { IonicStorageModule } from '@ionic/storage';
import {PayPal} from '@ionic-native/paypal';
import { FileTransfer } from '@ionic-native/file-transfer';
import { File } from '@ionic-native/file';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { LoginPage } from '../pages/login/login';
import {ChannelListPage} from '../pages/channel-list/channel-list';
import {ListsPage} from '../pages/lists/lists';
import { LoginService } from '../providers/login.service';
import { UserService } from '../providers/user.service';
import { FileServiceProvider } from '../providers/file-service';
import { CategoryService } from '../providers/category.service';
import { ChannelService } from '../providers/channel.service';
import { SubscriptionService } from '../providers/subscription.service';
import {SideMenuPage} from '../pages/side-menu/side-menu';
import { CategoryPage} from '../pages/category/category';
import { ChannelsPage} from '../pages/channels/channels';
import { FavoritePage} from '../pages/favorite/favorite';
import { ChannelPage} from '../pages/channel/channel';
import { CategoryDetailPage} from '../pages/category-detail/category-detail';
import {PlayerPage} from '../pages/player/player';
import {RegisterPage} from '../pages/register/register';
import {PaymentPage} from '../pages/payment/payment';
import {ProfilePage} from '../pages/profile/profile';
@NgModule({
declarations: [
ChannelListPage,
ListsPage,
MyApp,
HomePage,
LoginPage,
SideMenuPage,
FavoritePage,
CategoryPage,
ChannelsPage,
CategoryDetailPage,
PlayerPage,
ChannelPage,
RegisterPage,
PaymentPage,
ProfilePage
],
imports: [
BrowserModule,
HttpClientModule,
IonicModule.forRoot(MyApp),
IonicStorageModule.forRoot()
],
bootstrap: [IonicApp],
entryComponents: [
ChannelListPage,
ListsPage,
MyApp,
HomePage,
LoginPage,
SideMenuPage,
CategoryPage,
ChannelsPage,
FavoritePage,
CategoryDetailPage,
PlayerPage,
ChannelPage,
RegisterPage,
PaymentPage,
ProfilePage
],
providers: [
File,
FileTransfer,
StatusBar,
SplashScreen,
AppAvailability,
AndroidExoplayer,
InAppBrowser,
{provide: ErrorHandler, useClass: IonicErrorHandler},
FileServiceProvider,
LoginService,
CategoryService,
ChannelService,
SubscriptionService,
UserService,
PayPal
]
})
export class AppModule {}
I always get null user, help!!
ionic-framework ionic-storage
Im trying to set the user info when i login into the app and when i go to the profile page im trying to retrieve the data.
To set and get the user info Im using a separate service
import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable, EventEmitter } from '@angular/core';
import {Storage} from '@ionic/storage';
@Injectable()
export class LoginService {
private loginUrl = UrlService.APIURL+'/login/';
userEvent: EventEmitter<any> = new EventEmitter();
constructor(private http: HttpClient,
private storage:Storage) { }
public setStorageUser(user:any){
return this.storage.set('user', user);
}
public getStorageUser():Promise<any>{
return this.storage.get('user');
}
}
Setting value on Login Page
this.loginService.setStorageUser(userData).then(()=>{
this.navController.setRoot(HomePage);
});
Retrieving the user data on Profile page
this.loginService.getStorageUser().then((user)=>{
console.log(JSON.stringify(user));
});
App module page on my app
import { BrowserModule } from '@angular/platform-browser';
import { HttpClientModule } from '@angular/common/http';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { AppAvailability } from '@ionic-native/app-availability';
import { InAppBrowser } from '@ionic-native/in-app-browser';
import { AndroidExoplayer } from '@ionic-native/android-exoplayer';
import { IonicStorageModule } from '@ionic/storage';
import {PayPal} from '@ionic-native/paypal';
import { FileTransfer } from '@ionic-native/file-transfer';
import { File } from '@ionic-native/file';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { LoginPage } from '../pages/login/login';
import {ChannelListPage} from '../pages/channel-list/channel-list';
import {ListsPage} from '../pages/lists/lists';
import { LoginService } from '../providers/login.service';
import { UserService } from '../providers/user.service';
import { FileServiceProvider } from '../providers/file-service';
import { CategoryService } from '../providers/category.service';
import { ChannelService } from '../providers/channel.service';
import { SubscriptionService } from '../providers/subscription.service';
import {SideMenuPage} from '../pages/side-menu/side-menu';
import { CategoryPage} from '../pages/category/category';
import { ChannelsPage} from '../pages/channels/channels';
import { FavoritePage} from '../pages/favorite/favorite';
import { ChannelPage} from '../pages/channel/channel';
import { CategoryDetailPage} from '../pages/category-detail/category-detail';
import {PlayerPage} from '../pages/player/player';
import {RegisterPage} from '../pages/register/register';
import {PaymentPage} from '../pages/payment/payment';
import {ProfilePage} from '../pages/profile/profile';
@NgModule({
declarations: [
ChannelListPage,
ListsPage,
MyApp,
HomePage,
LoginPage,
SideMenuPage,
FavoritePage,
CategoryPage,
ChannelsPage,
CategoryDetailPage,
PlayerPage,
ChannelPage,
RegisterPage,
PaymentPage,
ProfilePage
],
imports: [
BrowserModule,
HttpClientModule,
IonicModule.forRoot(MyApp),
IonicStorageModule.forRoot()
],
bootstrap: [IonicApp],
entryComponents: [
ChannelListPage,
ListsPage,
MyApp,
HomePage,
LoginPage,
SideMenuPage,
CategoryPage,
ChannelsPage,
FavoritePage,
CategoryDetailPage,
PlayerPage,
ChannelPage,
RegisterPage,
PaymentPage,
ProfilePage
],
providers: [
File,
FileTransfer,
StatusBar,
SplashScreen,
AppAvailability,
AndroidExoplayer,
InAppBrowser,
{provide: ErrorHandler, useClass: IonicErrorHandler},
FileServiceProvider,
LoginService,
CategoryService,
ChannelService,
SubscriptionService,
UserService,
PayPal
]
})
export class AppModule {}
I always get null user, help!!
ionic-framework ionic-storage
ionic-framework ionic-storage
edited Jan 3 at 0:31
Okyam
asked Jan 2 at 18:41
OkyamOkyam
184310
184310
Hi! could you show more code from your service (where you set and get user info)? Specifically: are you injecting Storage in the constructor? Are you running this code after the deviceReady event?
– Nicolás Longhi
Jan 2 at 18:49
Thanks for your early response, i update the code.
– Okyam
Jan 2 at 18:56
Everything looks fine. Could you log the value of user before attempting to save it? Like this: public setStorageUser(user:any){ console.log(user); return this.storage.set('user', user); }
– Nicolás Longhi
Jan 2 at 19:19
I already logged the value in my home page after login and i get the information of the user, but when i go to my side menu and click to the perfil option it returns null, and when i tried to log the value in app.componet.ts is like at app.componet level storage is null because my side menu is configured in my app componet, Im not sure
– Okyam
Jan 2 at 19:29
This shouldn't be a problem because Storage should have only one instance within your app. Unless you are configuring the Storage module in multiple Modules in your app. So, if I understand correctly you can retrieve the user info from storage with that same code in your home page, but not in your side menu? In this case I would need to see the declaration of each component
– Nicolás Longhi
Jan 2 at 23:11
|
show 4 more comments
Hi! could you show more code from your service (where you set and get user info)? Specifically: are you injecting Storage in the constructor? Are you running this code after the deviceReady event?
– Nicolás Longhi
Jan 2 at 18:49
Thanks for your early response, i update the code.
– Okyam
Jan 2 at 18:56
Everything looks fine. Could you log the value of user before attempting to save it? Like this: public setStorageUser(user:any){ console.log(user); return this.storage.set('user', user); }
– Nicolás Longhi
Jan 2 at 19:19
I already logged the value in my home page after login and i get the information of the user, but when i go to my side menu and click to the perfil option it returns null, and when i tried to log the value in app.componet.ts is like at app.componet level storage is null because my side menu is configured in my app componet, Im not sure
– Okyam
Jan 2 at 19:29
This shouldn't be a problem because Storage should have only one instance within your app. Unless you are configuring the Storage module in multiple Modules in your app. So, if I understand correctly you can retrieve the user info from storage with that same code in your home page, but not in your side menu? In this case I would need to see the declaration of each component
– Nicolás Longhi
Jan 2 at 23:11
Hi! could you show more code from your service (where you set and get user info)? Specifically: are you injecting Storage in the constructor? Are you running this code after the deviceReady event?
– Nicolás Longhi
Jan 2 at 18:49
Hi! could you show more code from your service (where you set and get user info)? Specifically: are you injecting Storage in the constructor? Are you running this code after the deviceReady event?
– Nicolás Longhi
Jan 2 at 18:49
Thanks for your early response, i update the code.
– Okyam
Jan 2 at 18:56
Thanks for your early response, i update the code.
– Okyam
Jan 2 at 18:56
Everything looks fine. Could you log the value of user before attempting to save it? Like this: public setStorageUser(user:any){ console.log(user); return this.storage.set('user', user); }
– Nicolás Longhi
Jan 2 at 19:19
Everything looks fine. Could you log the value of user before attempting to save it? Like this: public setStorageUser(user:any){ console.log(user); return this.storage.set('user', user); }
– Nicolás Longhi
Jan 2 at 19:19
I already logged the value in my home page after login and i get the information of the user, but when i go to my side menu and click to the perfil option it returns null, and when i tried to log the value in app.componet.ts is like at app.componet level storage is null because my side menu is configured in my app componet, Im not sure
– Okyam
Jan 2 at 19:29
I already logged the value in my home page after login and i get the information of the user, but when i go to my side menu and click to the perfil option it returns null, and when i tried to log the value in app.componet.ts is like at app.componet level storage is null because my side menu is configured in my app componet, Im not sure
– Okyam
Jan 2 at 19:29
This shouldn't be a problem because Storage should have only one instance within your app. Unless you are configuring the Storage module in multiple Modules in your app. So, if I understand correctly you can retrieve the user info from storage with that same code in your home page, but not in your side menu? In this case I would need to see the declaration of each component
– Nicolás Longhi
Jan 2 at 23:11
This shouldn't be a problem because Storage should have only one instance within your app. Unless you are configuring the Storage module in multiple Modules in your app. So, if I understand correctly you can retrieve the user info from storage with that same code in your home page, but not in your side menu? In this case I would need to see the declaration of each component
– Nicolás Longhi
Jan 2 at 23:11
|
show 4 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54011540%2fionic-storage-is-null-when-i-call-storage-getkey%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54011540%2fionic-storage-is-null-when-i-call-storage-getkey%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Hi! could you show more code from your service (where you set and get user info)? Specifically: are you injecting Storage in the constructor? Are you running this code after the deviceReady event?
– Nicolás Longhi
Jan 2 at 18:49
Thanks for your early response, i update the code.
– Okyam
Jan 2 at 18:56
Everything looks fine. Could you log the value of user before attempting to save it? Like this: public setStorageUser(user:any){ console.log(user); return this.storage.set('user', user); }
– Nicolás Longhi
Jan 2 at 19:19
I already logged the value in my home page after login and i get the information of the user, but when i go to my side menu and click to the perfil option it returns null, and when i tried to log the value in app.componet.ts is like at app.componet level storage is null because my side menu is configured in my app componet, Im not sure
– Okyam
Jan 2 at 19:29
This shouldn't be a problem because Storage should have only one instance within your app. Unless you are configuring the Storage module in multiple Modules in your app. So, if I understand correctly you can retrieve the user info from storage with that same code in your home page, but not in your side menu? In this case I would need to see the declaration of each component
– Nicolás Longhi
Jan 2 at 23:11