Here's my code for a stacked http.get, which retrieves an object and then the object's details:
getDetails(sysID:string){
console.log("entered getDetails");
var details;
this.http.get('https://blahURL').map(res => res.json()).subscribe(
(data) => details = data, // Reach here if res.status >= 200 && <= 299
(err) => console.log(err), // Reach here if fails
()==>{ // On completion
console.log("reached end of first get");
this.http.get(...).map(res2 => res2.json()).subscribe(
(data2) => {return data2;
...
This is called via console.log(getDetails(sysID));
. So what I would expect is that when the second this.http.get() receives a result, it is passed to the caller and printed in the console.
However, what I get in console is:
entered getDetails
and then undefined
, and only after that reached end of first get
How would I force it to wait for the second http.get results?