【发布时间】:2020-03-26 12:13:17
【问题描述】:
ERROR Error Code: 500
Message: Http failure response for http://localhost:4000/api/update/5de40f285e9c793ed4af996c: 500 Internal Server Error
图片一是api服务
第一个代码块来自 api 服务,第二个代码块是 editcomponent
UpdateStudent(id, data: Student): Observable<any> {
let API_URL = `${this.endpoint}/update/${id}`;
return this.http.put(API_URL, data, { headers: this.headers }).pipe(
catchError(this.errorMgmt)
)
}
API 服务代码
updateStudentForm() {
console.log(this.studentForm.value)
var id = this.actRoute.snapshot.paramMap.get('id');
if (window.confirm('Are you sure you want to update?')) {
this.studentApi.UpdateStudent(id, this.studentForm.value).subscribe(res => {
this.ngZone.run(() => this.router.navigateByUrl('/students-list'))
});
}
}
}
【问题讨论】:
-
如果您收到状态码为 500 的错误:这意味着您的服务器中存在错误(检查您的 API)。