How do I map the user_id part of my response out to the user_id variable? My response is:
{"token":"1a68322c4cad219c94d9554e30e4c8a00339e428","user_id":23,"username":"test5","first_name":"test5","email":"[email protected]"}
I can get the first console.log(this.user_id) to show the user_id but the second one does not work. I want to use it to redirect me to another page..
login(user){
this.userApiService.login({'username': this.user.username, 'password': this.user.password}).subscribe( resp => {
let response = resp;
this.user_id = response.user_id
console.log(this.user_id)
});
console.log(this.user_id)
this.router.navigateByUrl('/dashboard/'+this.user_id)
}