Angular HTTP请求-标头编码错误

时间:2018-09-23 13:42:30

标签: angular encoding character-encoding frontend backend

来自我的后端的标题不是英语。当我在Angular中显示该标头时,编码已损坏。它显示如下:

  

Åpatnéheslo!

这是我发出http请求的方式:

login(email, password): Observable<any> {
const url = Utils.baseBackendUrl + '/login';
const headers = new HttpHeaders({
  'Content-Type': 'application/json;charset=utf8', 'Accept': 'application/json;charset=utf-8'
});
const locale = navigator.language;
return this.http.post<any>(url, JSON.stringify({'user_email': email, 'user_password': password, 'locale': locale.replace('-', '_')}),
  {headers: headers, observe: 'response', responseType: 'text' as 'json'});

}

0 个答案:

没有答案