Reputation: 567
I want to prepare some HTTP requests and after doing some things I want to execute them. For example:
this.requests.push(this.serviceExample.get())
..... // some things
this.request.executeRequests()
I've been searching on Internet but I was not able to find anything. I don't know if it is possible with Angular.
Upvotes: 0
Views: 52
Reputation: 7331
Sure.
Angular HttpClient
requests are not executed until they are subscribed to. You can subscribe to all using forkJoin
.
import { forkJoin } from 'rxjs';
executeRequests() {
forkJoin(...this.requests).subscribe()
}
Upvotes: 2