RxJS:在流中传输值

RxJS: Transfer values in stream

我想创建一个
1.使用getToken2方法获取token
2. 使用此令牌通过 flatMap
获取用户数据 3. 将刚刚接收到的userData和token(通过flatMap接收到的)分配给localStorage
问题是我无法在第二个映射方法中访问令牌。
那么如何在流中传输此令牌值以便我可以访问它。

  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');

         });
  }

请给我解决这个问题的想法。
亲切的问候

flatmapmergeMap 有一个名为 resultSelector 的可选参数。

A function to produce the value on the output Observable based on the values and the indices of the source (outer) emission and the inner Observable emission. The arguments passed to this function are:

outerValue: the value that came from the source
innerValue: the value that came from the projected Observable
outerIndex: the "index" of the value that came from the source
innerIndex: the "index" of the value from the projected Observable

return this.getToken2()
         .flatMap((token) => this.http.get(this.URL + '/ROS/profile?token=' + token),(token,response,outerIndex,innerIndex) => [token,response.json().data]))
         .map((response) => {
         //response is an array with both outer output and inner output.
             localStorage.setItem('currentUser', JSON.stringify({
               token:response[0], 
               userProfile: response[1]
             }));
             localStorage.setItem('orgId', response[1].structure.id);
             return this.toUser(response[1], '12');

         });