The following Firebase code returns a list of products in json:
firebase.database().ref('/products/').once('value');
In Angular2, what's the best way to convert this json to an array of product objects?
e.g. Array of product objects.
products: Product[];
e.g. Product object.
export class Product {
public id: string;
public name: string;
}
I see many references to Angular 2 http.get that use map e.g. https://angular.io/docs/ts/latest/guide/server-communication.html#!#sts=More%20fun%20with%20Observables
getHeroes (): Observable<Hero[]> {
return this.http.get(this.heroesUrl)
.map(this.extractData)
.catch(this.handleError);
}
But I don't understand how to use map or some other typescript convention to do this.