I have a class:
export class Stuff {
id: string;
namd: string;
}
With angular < 4.3 I have this call:
getStuff(): Observable<Stuff[]> {
return this.http.get('api-url-here/stuff')
.map((data: Response) => {
return data.json()
.map((item: any) => {
return {
id: item.id,
name: item.name
};
});
})
}
With angular >= 4.3 I changed it to this:
getStuff(): Observable<Stuff[]> {
return this.http.get<Stuff[]>('api-url-here/stuff')
.map((data: any) => {
return data
.map((item: any) => {
return {
id: item.id,
name: item.name
};
});
})
}
I am receiving the array of stuff fro my api that looking like that.
[
{"id":1,"name": "name" }
]
As you can see from the code example above I have to map the data twice to get my type shape (Stuff[]). Is there a better way of doing this with angular 4.3+ ?

[{"id":1,"name": "name" }]. I need to return the thing as I am doing insidegetStuff()just wondering is there any better way than just havingmap()..map()or may be I can have just singlemap()that I didnt figureout.commonpackage?@angular/common/httpHttpClientin my second example. I need to get all, so I am mapping over. I did map over twice with@angular/httpas I was gettingdata.json(). Now I do not need that but didn't figure out how to improve my doublemap()