12
rated 0 times
[
13]
[
1]
/ answers: 1 / hits: 53050
/ 9 Years ago, fri, october 23, 2015, 12:00:00
I understand using observable I can execute a method when the request is completed, but how can i wait till a http get is completed and return the response using in ng2 http?
getAllUser(): Array<UserDTO> {
this.value = new Array<UserDTO>();
this.http.get(MY_URL)
.map(res => res.json())
.subscribe(
data => this.value = data,
err => console.log(err),
() => console.log(Completed)
);
return this.value;
}
the value will is null when its returned because get is async..
More From » angular