I'd like to have a generic http get service I did it using the following code:
public get(module: String): Promise<any> {
return this.http.get(module)
.toPromise()
.then(response => response.json().data as Any[])
.catch(this.handleError);}
The problem is that now I'd like to know when the http.get is finished to fire a command and I don't know how to do it.
If I add something to the .then step it doesn't work
.then(response => response.json().data as Any[] && alert("HI"))
If I add a .then after the other then, it fires before the http request is fulfilled.
How can I achieve it?
Using dfsq code I'm able to fire alert("HI") but response is undefined. This is the way I use it:
this.dataService.get("myurl").then(response => console.log(response));
I get undefined
then(alert("Hi")).