I want to set one of the user detail that I am fetching from one of the API call in ngOnInit of my component.
But it is setting it as undefined. Although the API get called.
ngOnInit() {
sessionStorage.setItem('Key', this.currentUser());
}
currentUser(){
this.someService.getData().subscribe((res) =>{
res.body.name
})
}
I am getting the value undefined in the key when I am trying to access it. I am using angular 6.