title: how to manipulate localStorage parameters in ionic 2 i get undefined values
body: <p>i have struggles with the local storage parameter i have this //error SyntaxError at JSON.parse ()// i get " undefined" instead of the real values any help please on how to retrieve parameters from <strong>LocalStorage</strong> that i set after login in both my service <strong>auth-service.ts</strong> and <strong>auth.ts</strong>??!! </p>
  
  <p><strong>auth-service.ts</strong></p>
  
  <pre><code>      public loginChef(credentials) {
         if (credentials.email === null || credentials.password === null) {
           return Observable.throw("Please insert credentials");
          } else {
               return Observable.create(observer =&gt; {
  
            var url = 'http://localhost/PFEBACKEND/login-chef.php?
         email='+credentials.email+'&amp;passe='+credentials.password ;        
            this.http.get(url).map(res =&gt; res.json()).subscribe(
            data=&gt;{                                                                       
                  let access = (data.error=== 0 )
                   localStorage.setItem('nom',data.nom_contact);
                   localStorage.setItem('nom_societe',data.nom_societe);
                    localStorage.setItem('email',data.email);
                    localStorage.setItem('telephone',data.telephone);                      
             localStorage.setItem('matricule_fiscale',data.matricule_fiscale);
                    localStorage.setItem('role',data.role);
                     localStorage.setItem('id',data.id_chef);
                    this.member=data;
                    this.email=data.email;
                    this.nom=data.nom;             
                  // this.currentUser = new User( data.nom,data.email); 
                    observer.next(this.email,this.nom); 
                      //observer.next(this.member); 
                     //observer.next(access);  
                    // console.log(this.currentUser);
                     observer.complete(); 
                      },
                      err =&gt; {
                      console.log(err);
                       observer.next(err);
                      },
                        () =&gt; console.log('service observable') );
  
                  });
     }
   }
  </code></pre>
  
  <p><strong>offre.ts</strong></p>
  
  <pre><code>       offres: Array&lt;any&gt;;
          loader: any;
         id:string='';
  
  
  constructor(public navCtrl: NavController, public navParams: NavParams, 
  public data:Datamembers,private auth:AuthService, public 
  loadingCtrl:LoadingController)
   {
           if(localStorage.getItem('id')){//after login i store the user data
  
                 this.id=localStorage.getItem('id');                        
              }
  
   }
    ngOnInit()
      {  var id1=parseInt(this.id).valueOf();// i get undefined value
         this.presentLoading();    
         this.data.LoadOffres(id1).subscribe(
        //function LoadOffres accept int type parameter
            data =&gt; {
            this.offres = data;
            console.log(data);            
            this.loader.dismiss();
        },
        err =&gt; {
            console.log(err);
            console.log(id1);
            this.loader.dismiss();
        },
        () =&gt; console.log('chargement terminé')
    );
  }
  </code></pre>
  
  <p><strong>auth.ts</strong></p>
  
  <pre><code>      public loginChef() {
          this.showLoading();
          this.auth.loginChef(this.registerCredentials).subscribe(allowed =&gt; {
          if (allowed) {
              setTimeout(() =&gt; {
  
             this.email=this.auth.email;
             this.nom=this.auth.nom;
             this.currentUSer = this.auth.currentUser;
             this.member=this.auth.member;//array
  
            localStorage.setItem('email',this.email);
            localStorage.setItem('nom',this.nom);
             (....)
  </code></pre>