0

Here I make one Http request where i get the Account ID:

getAccountId(accessToken){
console.log(accessToken);
this.http.get('https://api.stackexchange.com/2.2/access-tokens/'+ accessToken)
.subscribe(data => {
       console.log(data.json().items[0].account_id);
    },
       error=>console.log(error)
  );
}

Using this account_id obtained there I want to make another Http call to this API to get the UserId:

 this.http.get('https://api.stackexchange.com/2.2/users/'+ this.AccountId +'/associated')

How do i do this? any solutions?

Samson Maben
  • 310
  • 2
  • 4
  • 15
  • 1
    Please edit your previous question if you think its not a duplicate. Don't ask the same question again in a different format. The link already states that you should be using `flatMap`. What is the issue? – eko Aug 17 '17 at 12:16
  • can i pass value from one http request to other http request using flatMap @echonax – Samson Maben Aug 17 '17 at 12:32
  • That's the whole purpose of `flatMap` – eko Aug 17 '17 at 12:32
  • In the above code after querying i have got the account_id . How do i pass this to the flatMap @echonax – Samson Maben Aug 17 '17 at 13:01
  • 1
    `this.http.get('https://api.stackexchange.com/2.2/access-tokens/'+ accessToken).flatMap((data)=> this.http.get('https://api.stackexchange.com/2.2/users/'+ data.json().items[0].account_id +'/associated')).subscribe((data)=> console.log(data);)` – eko Aug 17 '17 at 13:03
  • 1
    thank you it worked! Thanks a lot!@echonax – Samson Maben Aug 17 '17 at 13:15
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/152172/discussion-between-samson-and-echonax). – Samson Maben Aug 17 '17 at 14:57

0 Answers0