5
API가 반환하는 오류 본문을 어떻게 구문 분석 할 수 있는지 궁금합니다. Angle 2의 구문 분석 본문
이
이 API 리턴의 이미지 : 나는 URL에 액세스 할 수 있습니다login(username,password){
let headers = new Headers();
headers.append('Content-Type','application/json');
return this.http.post(this.configEnvironment.url() + "oauth/access_token",
JSON.stringify(
{
username: username,
password: password,
grant_type: "password",
client_id: "xxxxxxx",
client_secret: "xxxxxxxx"
}
),
{ headers }
)
.map(res => res.json())
.catch((err:any) =>{
console.log(err);
return Observable.throw(new Error(err));
});
}
, 상태,하는 statusText 등이 사용 :
err.status,err,url,error.statusText
을 여기
은 내 코드입니다
내 문제는 내가 오류 본문의 가치를 얻을 수 없다는 것입니다.
Thanks Man! 이 내 문제를 해결 –
@SydneyLoteria 아무 문제 없습니다. 방금 한 것처럼'any'에서'Response'로'err'의 타입을 변경하면 더 나은 IDE 지원을받을 수 있습니다. – BeetleJuice
Angular 5 @ Angular/Common/http 방법은 무엇입니까? –