1
值传送我想创建一个可观察其
1.获取令牌getToken2方法
2.使用此令牌来获得用户数据与flatMap
3.分配刚刚收到用户数据和令牌(这是通过flatMap收到)到localStorage
问题是我无法访问第二个映射方法中的令牌。
那么我怎样才能在流中传递这个令牌值,以便我可以访问它。RxJS时:物流
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');
});
}
请给我想法来解决这个问题。
此致
价值的“指标”谢谢你这么多伟大的解决方案。它真的帮了大忙! –