I'm writing an Angular app. I have a service that makes an http request like this:
export class PingService {
constructor(
private http: HttpClient) { }
ping() {
return this.http.get<{ip, type}>(this.apiRoutes.pingService);
}
}
I call this service inside a component:
login(credentials) {
this.invalidLogin = false;
this.pingService.ping()
.subscribe(data => {
this.apiConfigService.changeNetwork(data.type);
},
error => {
throw(error);
});
// MORE THINGS TO DO //
I want to wait for the pingService.ping() to finish before executing the // MORE THINGS TO DO //. How can I wait for the service to finish?
subscribethen..MORE THINGS TO DOinside the subscribtion of the service method