我知道这个问题已经被问过,但我找不到任何合适的解决方案。
我正在尝试做一个post
要求。该 API 需要一个x-www-form-urlencoded
正文格式所以我最终这样做了:
login(account: LogAccount): Observable<any> {
const body = new HttpParams()
.set('username', account.username)
.set('password', account.password);
const headers = new HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded' });
return this.http.post(`${environment.api.apiUrl}/loginservice`, body.toString(),
{ headers });
}
这导致 :
使用 Postman 一切正常。
我在这里缺少什么?
谢谢
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)