How to handle multiple http request response in Angular 8?


I have invoke one http request to my third party web api site, they have verified and redirect multiple response at internally (i.e. Status code is 200, 302)

But in mean time I have received response at client side and proceed with success block and few seconds later, it went to error block as well.

In .ts file:

                .subscribe((data: any) => {
                    alert('inside success block');
                (clientErr) => {
                     alert('inside error block');

**In form.service file:**
public authenticateResource(requestURL: string): any {
let headers = new HttpHeaders({
            'Authorization': this.authService.authToken         
        var req = new HttpRequest(
            { headers: headers },
            { withCredentials: true }

        return this.http.request(req);

I am facing this issue from Angular 5+ on wards. In Angular 2 it works fine.

Is anyone facing like this issue?


I edited your post to make the code more readable. In the future, when posting code, just highlight it and press the “preformatted text” button (it looks like </>) or press Shift-Ctrl-C (for “code”) and it will format your code properly.

Oh, and welcome to freeCodeCamp! :grinning: