Is there a way to pause the execution of my code until a subscribe function is complete?
I have a subscribe function within another function, and I want to ensure that the outer function only finishes once the subscribe function has executed.
Here is my Subscribe Function:
this.massService.getMass(token, userId).subscribe((data: IMass) => {
// Execution
})
And here is my Service Function:
getMass(token: string, userId: string): Observable<IMass> {
const httpParams = new HttpParams().set('userId', userId);
const options = {
params: httpParams,
headers: new HttpHeaders().set('Authorization', 'Bearer ' + token)
};
return this.http.get<IMass>(environment.apiUrl + '/mass', options);
}