I m trying to pass changePasswordDto to RestApi, i created 2nd Put request
[HttpPut("updatePassword")]
public ActionResult<User> Put([FromBody] ChangePasswordDto newPass)
{
return Ok("Hi Boy");
}
In angular it looks like that:
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);
}
i put a breakpoint to restApi but it doest go there. when i m checking in postman its allgood, https://localhost:44375/api/user/updatePassword works and hits breakpoint in Controller. Why it doesnt go to api from angular. Thanks
CodePudding user response:
It's because http.put
returns an Observable, it won't be executed until you .subscribe
to it.
this.http.put<any>(environment.apiURL '/api/user/updatePassword', this.changePasswordDto)
.subscribe(response => /* do something here */ );