I'm stuck with this problem. Sharing the simplified pseudo code below:
forkJoin({
requestOne : this.http.get<Response>('https://someapirequest.com/test/api/stop/closest')
.pipe(
map((val:Response) => val.busStopList),
map( val => val.map(q => q.stopId)),
tap(ev => console.log('the results till now:', ev)
// here is the line ************* [1]
// ["123", "234", "678" ...]
{{ I have to make some http requests here }}
.
.
.
),
requestTwo: this.http.get<Response2>('https://someapirequest.com/test/api/stop/closest?anotherone=abc')
.
.
.
in the code above in line[1] I am getting a string array like this ["123", "234", "687"..] in the tap operator wihch is totally fine. It's what I want to have till that line. but after that line I have to make sequential http requests with items of this array. For example, after line[1], I have to make these requests:
{array item here}
|
this.http.get('https://someapirequest.com/test/api/stop/closest?item1=123')
{array item here}
|
this.http.get('https://someapirequest.com/test/api/stop/closest?item2=234')
{array item here}
|
this.http.get('https://someapirequest.com/test/api/stop/closest?item3=687')
I tried so many things, but couldn't reach the solution. The las point I have reached out is:
.
.
.
requestOne : this.http.get<Response>('https://someapirequest.com/test/api/stop/closest')
.pipe(
map((val:Response) => val.busStopList),
map( val => val.map(q => q.stopId)),
// in that point I have an **array** like this: ["123", "234", "678"]
map(x => from(x)), // [2]
concatMap(arrayItem => {
return this.http.get('https://someapirequest.com/test/api/stop/closest?item1=${arrayItem}')
}) // [3]
.
.
.
But couldn't reach the solution. I tried converting array to observable with from in [2], and tried to make requests with concatMap over iterated values but failed. Is there any way?
You can't imagine how happy I would be with some help.