Call within constructor returns undefined


#1

Hello fellow programmers,
How can I get the IP address into that URL: http://localhost/index.php?ip=

export class HomePage {
	posts: any;
	email: string;
	ip: any;
	
  constructor( public loadingController: LoadingController, private auth: AngularFireAuth, public http: Http ) 
	{
		let loader = this.loadingController.create({content: "Please wait..."});  
		loader.present();
		var = this.http.get("https://api.ipify.org/?format=json").map(res => res.json()).subscribe(data => {this.ip = data.origin;});
		this.auth.authState.subscribe((user)=> {
			this.email = user.email //kept for user email in homepage
			this.http.get('http://localhost/index.php?ip=' + this.ip + '&email=' + user.email).map(res => res.json()).subscribe(data => {
			this.posts = data.syntx;
			loader.dismiss();
			});	
		});
	
    
		//console.log(this.email);
	}
	
	signOut() {this.auth.auth.signOut();}
}

#2

see https://coryrylan.com/blog/angular-multiple-http-requests-with-rxjs


#3

Actually It only works outside the constructor.
But I mean how can I call the output of

this.http.get("https://api.ipify.org/?format=json").map(res => res.json()).subscribe(data => {this.ip = data.origin;});

in

this.http.get('http://localhost/index.php?ip='