HttpClient와 함께 요청을 보내고 있으며 응답을 구문 분석 할 수 없습니다. @ angular/http의 http를 사용하면 response.json(). token을 호출해도 문제가되지 않지만 HttpClient에는 존재하지 않습니다. 여기HttpClient from @ angular/common/http
내 요청 :
return this.httpClient.post(environment.baseUrl + '/api/authenticate', JSON.stringify({ username: username, password: password }))
.map((response: Response) => {
//response.json() --> leads to an exception
...
응답은 다음과 같습니다 {응답 = { "토큰": "ABCD ... XYZ"}}
HttpClient를이 사용 할 수 없습니다 ? 이전 Http
서비스와는 달리
왜 정상적인 http를 사용하지 않습니까? – mast3rd3mon
기본값은 HttpClient에서'response.json()'입니다. https://stackoverflow.com/questions/45129790/difference-between-http-and-httpclient-in-angular-4 – echonax