I know that has a lot of questions about this, but i tried a lot of tips and the problem persists.
i implement a get that return an observable:
public getEstatisticasPara(motorista:Motorista): Observable<EstatisticaAvaliacao> {
let params = new URLSearchParams();
params.set(Config.ESTATISTICA_AVALIACAO_REQUEST_PARAM, motorista.getId().toString());
let options = new RequestOptions({ headers: this.headers, params: params });
return this.http.get(this.path, options)
.map((res) => res.json)
.catch(this.handleError);
}
When i try to subscribe always get a undefined:
atualizaMediaAvalicaoes(){
let motorista:Motorista = FlyweightFactory.getInstanceOf("motorista");
motorista.setId(1);
this.estatisticaAvaliacaoProvider.getEstatisticasPara(motorista)
.subscribe((res)=>{
console.log(JSON.stringify(res));
let estatisticaAvaliacao:EstatisticaAvaliacao = EstatisticaAvaliacao.fromJson(res);
this.storage.set("mediaAvaliacao", estatisticaAvaliacao.getMedia());
},(err)=>{
console.log(err);
});
}
Network console show correct response... so why the undefined ? =/
Httpservice or the newHttpClient? And how does yourresobject looks like ? Becauseres.jsonseems strange. - cyr_xlooks strange:) - cyr_x