Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70762

Cannot assess the http post response data from outside of the .subscribe

$
0
0

@thilinanara wrote:

I am using a http request to get a url from a server and it returns correct data as the response. after i set the data to a variable i cannot access the variable data from other method.

this is my code

public  urlcheck:any;

constructor(public http: Http) {

   //what i want to do is something like this, it works when i do like this.
   //urlcheck = "http://10.0.2.2/mysite/";


   this.urlcheck = this.http.get('http://localhost/website/index.php/Admin/getpublicip');
   this.urlcheck.subscribe(data => {
      //console output is  ('my data: http://10.0.2.2/mysite')
      console.log('my data: ', data["_body"]);
      this.urlcheck = data["_body"];

   })
//console output is ("check url[object Object]")
console.log("check url"+this.urlcheck);
}

what am i missing?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70762

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>