user9759491
user9759491

Reputation:

Angular Backend HTTP Request

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

Upvotes: 1

Views: 69

Answers (1)

Mr.Manhattan
Mr.Manhattan

Reputation: 5504

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
});

Upvotes: 2

Related Questions