i have a trouble about calling a service in my component so the data go null alwyas . this is the example :
the service method :
getOneUser() {
return this._http.get(globals.serverIp + '/user/getOneUser/' + this._ls.getCurrentUserName(), { headers: this.headers})
.map((response: Response) => <UserParser> response.json());
}
the method in component :
updateParametre(message: string){
let currentUser = new User();
this._us.getOneUser().subscribe(
data =>currentUser = data.data,
error => console.log('error from updateParam ParamtereComponenet ' + error),
() => console.log(currentUser)
);
let anotherinstance : User = currentuser ;
console.log(currentUser);
}
trying to console the currentUser inside the subscribe method:
{id: 9,
initials: "YCI",
nom: "CHABLI",
prenom: "Yassin",
password: "$2a$10$iWVnXs/2TwOk7CBr5RuQ.e/1c/BTlxsvkjHyYrtOgKUiRMll2EupO"}
but the object anotherintance go null , and also trying to console the currentUser out of the subscribre go null ..
what is the problem , please ?