I have the following code that is working, but I feel like there is a much simpler way of doing this with rxjs. Does anyone know how this can be simplified? The main reason for the complexity is I need to run the custom constructor on each item in the array before I can return it to the subscribing method. (Angular 8.2.3, Typescript 3.5.3, rxjs 6.4.0)
getAllthings() : Observable<Object>{
const apiUrl = `${this.baseUrl}/things`;
return this.http.get<Array<Thing>>(apiUrl).pipe(
map((itemsArray) => {
itemsArray.forEach(function(item, index, array) {
array[index] = new Thing(item);
});
return itemsArray;
}));
}