I want to create an observable which
1. Gets token with getToken2 method
2. Use this token to get userdata with flatMap
3. Assign just received userData and token( which was received via flatMap) to localStorage
The problem is that I am unable to access the token in second map method.
So How can I transfer this token value in stream so I can access it.
getCurrentUser2() {
return this.getToken2()
.flatMap((token) => this.http.get(this.URL + '/ROS/profile?token=' + token))
.map((res) => res.json().data)
.map((response) => {
localStorage.setItem('currentUser', JSON.stringify({
token:token, ,**want to access token value here**
userProfile: response
}));
localStorage.setItem('orgId', response.structure.id);
return this.toUser(response, '12');
});
}
Please give me idea to solve this issue.
Kind Regards