1

I want to send an HTTP POST request to my backend in Ruby on Rails, Unfortunately, the backend does not receive any request.

Heres my code:

const params = new HttpParams()
        .set('subject', this.dialogForm.controls['subject'].value)
        .set('start_date', moment(this.dialogForm.controls['startDatePicker'].value).format('YYYY-MM-DD HH:mm:ss').toString())
        .set('due_date', moment(this.dialogForm.controls['dueDatePicker'].value).format('YYYY-MM-DD HH:mm:ss').toString())
        .set('description', this.dialogForm.controls['description'].value);
      console.log(params);

      this.http.post(API_BASE_URL + 'angular_calendar/custom_meetings/create', ' ', {params})
        .pipe(
          catchError(this.handleError)
        );

Does anyone have an idea how to solve this

2
  • http requests are only sent when the observable returned by post() is subscribed to. Commented Jan 27, 2021 at 12:17
  • Observables are lazy. You need to subscribe to them to trigger them. this.http.post(...).subscribe(...) Commented Jan 27, 2021 at 12:18

1 Answer 1

2

http requests are only sent when the observable returned by post() is subscribed to.

this.http.post(API_BASE_URL + 'angular_calendar/custom_meetings/create', ' ', {params}).pipe(
    catchError(this.handleError)
).subscribe(result => {
    // do something with the result
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.