我有这个功能:
public getAssignedOrganizations() : Observable<any> {
return this.http.get(this.settings.backend.assignedOrganizations)
.flatMap((org) => {
return this.http
.get(this.settings.backend.warehousesByOrg + org.organization_id)
.map((res: any) => res.json());
})
.catch((error:any) => Observable.throw(error || 'Server error'));
}
org
将返回一个对象数组,因此flatMap
无法理解该参数。如何迭代第一个HTTP
请求(org
)的响应,以便我可以调用第二个HTTP
?我做错了什么?
答案 0 :(得分:0)
map
运算符将在flatMap
public getAssignedOrganizations() : Observable<any> {
return this.http.get(this.settings.backend.assignedOrganizations)
.flatMap((org) => {
return this.http.get(this.settings.backend.warehousesByOrg + org.organization_id)
})
.map((res: any) => res.json());
.catch((error:any) => Observable.throw(error || 'Server error'));
}