Angular后端HTTP请求



我想发送一个HTTP POST请求到我的后端Ruby on Rails,不幸的是,后端没有收到任何请求。

下面是我的代码:

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

有人知道怎么解决这个问题吗

http请求只有在post()返回的可观察对象被订阅时才会发送。

this.http.post(API_BASE_URL + 'angular_calendar/custom_meetings/create', ' ', {params}).pipe(
catchError(this.handleError)
).subscribe(result => {
// do something with the result
});

最新更新