在以下函数中,变量凭据作为参数传递。我将凭据对象的值记录到控制台,并且它们与预期的一样。然后,我使用JSON.stringify()将凭据转换为字符串,然后更改值。
这是功能。
public signIn(credentials) {
console.log('credentials', credentials)
let body = JSON.stringify(credentials);
console.log('body', body)
return this.httpClient.post(this.userUrl, body, httpOptions)
.pipe(
tap(token => console.log('token', token)),
catchError(this.handleError.bind(this))
)
}
console.log('credentials',凭据)产生以下值,每个值的首字母均为X:
credentials
Object
email: "Xadmin@admin.com"
name: "XJohn Admin"
password: "Xadmin"
__proto__: Object
console.log('body',body)会产生以下值,并且缺少X:
body {"name":"John Admin","email":"admin@admin.com","password":"admin"}