2
上午使用angular2与Django rest Api。我试图在波纹管的代码服务来检索使用HTTP GET一笔账:Django Rest angular2 http获取
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')});
}
是有效的我错过了回报感谢ü这么多 – sila