我正在嘗試將 changePasswordDto 傳遞給 RestApi,我創建了第二個 Put 請求
[HttpPut("updatePassword")]
public ActionResult<User> Put([FromBody] ChangePasswordDto newPass)
{
return Ok("Hi Boy");
}
在角度它看起來像這樣:
changePassword(newPass: string) {
this.currentUserId = this.authService.getUserID();
this.changePasswordDto = {
newPW: newPass,
userId: this.currentUserId
}
return this.http.put<any>(environment.apiURL '/api/user/updatePassword', this.changePasswordDto);
}
我在 restApi 上放了一個斷點,但它沒有去那里。當我簽入郵遞員時,它的一切都很好,https://localhost:44375/api/user/updatePassword 作業并在控制器中命中斷點。為什么它不從角度轉到 api。謝謝
uj5u.com熱心網友回復:
這是因為http.put回傳一個 Observable,直到你執行它才會執行.subscribe。
this.http.put<any>(environment.apiURL '/api/user/updatePassword', this.changePasswordDto)
.subscribe(response => /* do something here */ );
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/407046.html
標籤:
上一篇:發布請求上的位置與內容位置
