2
Am benutze angular2 mit Django Rest Api. mit http get in einem Dienst im Code versuche ein Konto abzurufen Gebrüll:Django Rest angular2 http bekommen
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);
}
Sie versuchen, wann diese Methode in der Komponente zu beheben:
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')});
}
bekam ich eine Antwort mit http ok, aber das Konto in der Komponente ist nicht definiert:
Ja effektiv vermisste ich eine Rückkehr danken u so much – sila