I'm doing a GET to login, however I need to get the user ID for the session too:
submit(){
var link = 'http://localhost:1337/usuario?email='+ this.usuario.email + '&senha='+ this.usuario.senha;
var data = JSON.stringify({ email: this.usuario.email, senha: this.usuario.senha});
this.http.get(link)
.subscribe(data => {
this.data.response = data._body;
if(this.data.response != "[]"){
console.log(this.data.response);
// tinha que pegar o ID do usuário.... :/
sessionStorage.setItem("usuarioEmail", this.usuario.email);
sessionStorage.setItem("flagLogado", "sim");
this.navCtrl.setRoot(WellFitPage, {}, {animate: true, direction: "forward"});
}else{
let alert = this.alertCtrl.create({
title: 'Usuário Não encontrado!',
subTitle: 'Verifique se digitou seu e-mail e senha corretamente.',
buttons: ['OK']
});
alert.present();
}
})
}
My:
console.log(this.data.response);
Print this result in Console:
[
{
"nome": "Ramos",
"email": "[email protected]",
"celular": "34996320391",
"telefone": null,
"data_nascimento": null,
"altura": null,
"peso": null,
"gordura": null,
"vo2": null,
"senha": "teste",
"cmkey": null,
"id": 4,
"createdAt": "2018-03-28T18:08:22.000Z",
"updatedAt": "2018-03-28T18:08:22.000Z"
}
]
How to get the id?