此代码有问题。我正在尝试从辅助端点收集与第一次获取的返回集合中的id有关的其他详细信息。有人可以帮忙如何在返回可观察值数组时获取实际数据。谢谢
crypto.createHmac(
CONSTANTS.HMAC_ALORITHM_SHA,
Buffer.from(
secretAccessKey,
CONSTANTS.BASE64_ENCODING
)
).update(
Buffer.from(
stringToSign,
CONSTANTS.UTF8
)
).digest(
CONSTANTS.BASE64_ENCODING
);
答案 0 :(得分:4)
您可以使用map
来代替switchMap
:
forkJoin
如果要保留该值,可以尝试执行以下操作:
this.http.get(`${this.apiUrl}/cinemas/location/cardiff`).pipe(
map((data: any) => data.cinemas),
switchMap((cinemas) => forkJoin(cinemas.map(value => <Observable<any>>this.http.get(`https://api.cinelist.co.uk/get/cinema/${value.id}`));
}))
).subscribe(results => {
console.log(results);
});
答案 1 :(得分:0)
this.http.get(`https://api.cinelist.co.uk/search/cinemas/location/${town}`).pipe(
map((data: any) => data.cinemas),
flatMap((cinemas) =>
forkJoin(
cinemas.map(value => {
return this.http.get(`https://api.cinelist.co.uk/get/cinema/${value.id}`).pipe(
map((result: any) => {
return { ...result, ...value };
}));
})
)
)
).subscribe(x => {
console.log(x);
});