I have an array of HTTP requests that I need to fire in certain order, but if any of the previous one fails then none of the following ones is going to be executed.
How can I achieve that?
What's the best approach?
I need something like:
let failed: boolean = false;
payloadArray.forEach(payload => {
if (!failed) {
http.post(this.url, payload, this.options)
.map((res: Response) => {
return res.json;
})
.catch((error: any) => {
failed = true;
Observable.throw(error.json().error || 'Server error')
});
}
}