I currently have a problem with Angular2 and Observable object.
I have a Component who calls a Service : a real one linked to an api and a fake one.
The service linked to the API works well but when I use the fake one, I want to return an Array from Observable object but I have this error :"Observable_1.Observable.fromArray is not a function"
Here is my code :
Component :
this._raceService.list().subscribe(newRaces => {
this.races = newRaces;
});
Real Service :
list(){ return this._http.get('http://dev.backend.com/api.php', options).map(res => res.json()); }
Fake service :
list() { return Observable.fromArray([{ name: 'London' }]); }
Can you help me plz ?
Cheers
should that be...
Rx.Observable.from(yourarray)
fromArray seems to be deprecated
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With