Skip to content

Instantly share code, notes, and snippets.

@ppaska
Last active October 12, 2022 17:33
Show Gist options
  • Save ppaska/1af5457f81931c1bdb71d34f3ccd5c69 to your computer and use it in GitHub Desktop.
Save ppaska/1af5457f81931c1bdb71d34f3ccd5c69 to your computer and use it in GitHub Desktop.
How To Make a Parallel Http call in JSPython
from 'rxjs' import forkJoin, lastValueFrom, map
ids = [2, 7, 4, 9, 5]
httpRequests$ = ids
.map(
requestId => httpRequest$("GET", "https://jsonplaceholder.typicode.com/posts/" + requestId)
.pipe(
map(r => {requestId, response: r.data})
)
)
return lastValueFrom(forkJoin(httpRequests$))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment