CodeZettaInterview Hub

Angular · HTTP · Mid-Level · Debugging

How do you cancel an in-flight HTTP request when navigating away?

Short Interview Answer

Unsubscribe (async pipe / takeUntilDestroyed) or switchMap in a stream that completes on destroy.

Detailed Explanation

HttpClient aborts when unsubscribed. switchMap cancels previous searches. Don't leave orphan subscriptions.

Did you know this answer?