@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