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');
});
}
請給我想法來解決這個問題。
此致
價值的「指標」謝謝你這麼多偉大的解決方案。它真的幫了大忙! –