Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

286
Views
Observable creates infinite loop when http request fails

I use Observable in my Angular 4 application to load data from a web api.

Have a service that looks like this:

import { Injectable, Output, EventEmitter } from '@angular/core';
import { Http } from '@angular/http';

@Injectable()
export class WorkgroupsService {

    constructor(private _http: Http) {

    }

    getWorkgroups() {
        return this._http.get(`/api/security/getsecurityworkgroups`).map(res => res.json());
    }
}

And use it something like this:

loadWorkgroups() {
    this._workgroupsService.getWorkgroups()
        .subscribe((workgroups: any) => {
            this.workgroups = workgroups;
        });
}

Whenever the api returns an error it creates an infinite loop, the request is sent over and over again.

How can I stop it?

Thanks!

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!