I developed a function to retrieve filtered results from a JSON dataset.
getItem(id: string): Observable<any[]> {
return this.http.get('path/to/my.json')
.map((response) => {
let results: any = response.json();
let filtered: any = results.filter((result) => {
return result.field === id;
})[0];
return filtered;
}
);
}
Now I need to update my service since the parameter (id) is no longer a string, but an array. How should I modify my function? Currently, if 'id' is an array, it returns an Array containing all objects from my JSON dataset.