2
장고용 휴식 Api와 함께 angular2를 사용하고 있습니다. 울부 짖는 코드에서 서비스에 HTTP GET을 사용하여 계정을 검색하려고하면 :Django rest angular2 http get
getAccountBackend(id: string) : Promise<any> {
const slash="/"
const urlaccount = `${this.urlAccontBackend}${id}${slash}`;
console.log('url du compte', urlaccount)
return this.http.get(urlaccount)
.toPromise()
.then(response => {
response.json().data
console.log(response)}
)
.catch(this.handleError);
}
시도가 구성 요소에서이 방법을 해결하는 경우 :
getAccountById(){
console.log("i will resolve the account");
this.fcbAccSrv.getAccountBackend('1234896')
.then(data=> {
this.compte=data
console.log("the account from the backend", this.compte);
})
.catch(error =>{ this.error = error;
console.log('error to resolve account')});
}
나는 확인 HTTP 만에 응답을 얻었다 당신은 return
누락
예 효과적으로 내가 수익을 놓친 유 너무 감사합니다 – sila