Angular 6 SyntaxError:JSON.parse 位置 0 处的 JSON 中出现意外标记 <

2024-02-21

我知道这个问题已经被问过,但我找不到任何合适的解决方案。

我正在尝试做一个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(使用前将#替换为@)

Angular 6 SyntaxError:JSON.parse 位置 0 处的 JSON 中出现意外标记 < 的相关文章

随机推荐