Show login data on another page

I used native Storage and it works with the chrome extension.
Now i have another problem


The Login Code

 connexion(){
  var headers = new Headers();
  headers.append('Content-Type', 'application/x-www-form-urlencoded');
   
  var params = 'email='+this.userData.email+'&passe='+this.userData.passe;
  this.http.post(apiUrl, params , {headers: headers})
  .subscribe(
    data => {
      //this.responseData = data,
      //console.log(this.responseData),
      this.storage.set('utilisateurData', data);
      this.navCtrl.push('ProfilPage');
    },
    err => {
      console.log(err);
    },
    () => console.log('Call Complete')
  );

}

The Profil TS Code

 userDetails : any;
  responseData: any;
  userPostData = {"user_id":"","token":""};
  constructor(public navCtrl: NavController, public navParams: NavParams, public authService:AuthServiceProvider, public app: App,private storage: Storage) {
      this.storage.get('utilisateurData').then((data) => {
      
      this.userDetails = data.userData;
      console.log(data.first_name);
      this.userPostData.user_id = this.userDetails.id;
      this.userPostData.token = this.userDetails.remember_token;
    });

  }

HTML PART

  <h2>Welcome to {{userDetails.first_name}} {{userDetails.last_name}}</h2>
  <h3>Email: {{userDetails.email}}</h3>

console.log() this to see content. End up, if it’s json format try JSON.parse(…)

I used Ionic Storage

I tried

this.userDetails = data;

Your data is into array. Try this.userDetails = data[0];
By the way… never send password user from database through api return
In Laravel you can dos this in your model user class :

protected $fillable = ['Nom','Prenoms','Sexe','Email','password','IdProfil','Statut','created_by','updated_by'];
protected $hidden = ['password'];

In laravel i used database to get user info

$user=\DB::table('tb_users')->where('email',$username)->get();

My User Model Class is like this

<?php namespace App\Models\Core;

use App\Models\Sximo;
use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;

class Users extends Sximo  {
	
	protected $table = 'tb_users';
	protected $primaryKey = 'id';

	public function __construct() {
		parent::__construct();
		
	}

	public static function querySelect(  ){
		
		return " SELECT  tb_users.*,  tb_groups.name 
FROM tb_users LEFT JOIN tb_groups ON tb_groups.group_id = tb_users.group_id ";
	}	

	public static function queryWhere(  ){
		
		return "    WHERE tb_users.id !=''   ";
	}
	
	public static function queryGroup(){
		return "      ";
	}
	

}

and this.userDetails = data[0]

It seem that your problemn is into view ProfilPage.html. Are you try **somedata.id** in your view ?

Yes {{userDetails.id}}

But also when i try a console log for userDetails.id it’s undefined

What console.log(userDetails) show ?

Capture

Try console.log(userDetails[0]) and let me know…

It only show undefined

As i see in the body response, the content is string value. _body: "[{“id”:9,“group_id”… instead of json or array
CAn you show your controller return value from Laravel side ?

It return JSON

$user=\DB::table('tb_users')->where('email',$username)->get();
               // die();
                //return "success";
                return json_encode($user);

Strange… try return response()->json($user)

It doesn’t change anything, it gives undefined

with console.log(userDetails[0]) or console.log(userDetails)

With

console.log(userDetails[0]) 

and with the other, it gives all the results

what console.log(data) show ?

Capture