I'm using @angular/http get to fetch data from server, here is my code :
private _currentPT: any;
public phongtroDetailChange = new Subject();
layPhongtro(id: number): Promise<any> {
return new Promise((resolve, reject) => {
this.http
.get(Constants.apiUrl + 'phongtro/' + id, { headers: Constants.headers })
.map((resp: Response) => resp.json())
.subscribe(resp => {
console.log(resp);
// if (!resp.result) {
// this._currentPT = resp;
// this.phongtroDetailChange.next(true);
// resolve(resp);
// } else {
// this.handleError('layPhongtro', resp.result);
// reject(resp.result);
// }
},
error => this.handleError('layPhongtro', error));
});
}
When I commented code like that, the property "tiencoc" of resp has right value which means its value is 0, here is the picture of console.log
https://i.sstatic.net/7oYGW.png
But when I uncommented, the value of "tiencoc" is the same as property "giatien", now its value is 1000000, here is picture of console.log when uncommented
https://i.sstatic.net/rGxdI.png
I dont know why ? Pls help me, thank you so much
P/s: I have tested with POSTMAN and the resp is OK, which means "tiencoc"'s value is 0
console.log(resp)
intoconsole.log(JSON.stringify(resp));
and tell what the value of tientoc is then?