【发布时间】:2021-10-07 14:51:26
【问题描述】:
我的 API 端点返回 json 作为键值对结果。如何将此集合映射到 .pipe 方法中的对象 ICar 。我需要 observable,因为我想缓存结果。
示例 json 结果:
{"1":"Ford", "2":"Toyota"}
我的示例代码:
export interface ICar {
key: string;
carName: string;
}
getCars():Observable<ICar[]> {
return this.httpClient.get("https://cars.com/cars")
.pipe(
map(???), <--------------dont't know how to map it here
publishReplay(1),
refCount()
);
}
【问题讨论】:
标签: angular rxjs observable