Last active
October 12, 2022 17:33
-
-
Save ppaska/1af5457f81931c1bdb71d34f3ccd5c69 to your computer and use it in GitHub Desktop.
How To Make a Parallel Http call in JSPython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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