2020-02-05 15:51:48
JavaScript
, 2020-02-05 15:51:48

Angular sends api request infinite times?

Whoo, guys. What to do if a request to api is sent an infinite number of times? Send json via subscribe, using a button.

Button

<button class="btn btn-primary save-button" (click)="OnSumbit()">Save</button>


this.bookingService.createBookingOptions(this.formArr.controls[i].value).
        subscribe(result => {
          console.log(result);
          localStorage.removeItem("placeForm");
          this.navigationService.navigate(`Places`, false);
        });


the request itself
public createBookingOptions (data: any): Observable<any> {
        return this.httpService.post<any>(`/booking_options/`, data);
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2020-02-05
@Stalker_RED

set a breakpoint and find out why.
Apparently there is an infinite loop, or something like that.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question