Answer the question
In order to leave comments, you need to log in
Why is there a toPromise method in angular 4?
Hello.
I have a method
getAllUsers(){
return this.http.get('/api/users')
.map(res => res.json());
}
The documentation says that you need to use the Promise method. Why is it needed?
getAllUsers(): Promise {
return this.http.get('/api/users')
.toPromise()
.then(response => response.json().data as User[])
.catch(this.handleError);
}
Thank you.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question