Fetch multiple, and return first returned?

Is it possible to fetch() 2 resources, and then return the first response? (i.e., the one that’s returned the fastest).

I’m pretty sure that’s possible, since I recall seeing code for this a while back. But I really cannot find where I saw that, despite intensive searching.

Might someone know what I refer to, and point me in the good direction?

Thanks! :slight_smile:

You’re right it exists, but you probably didn’t search for Promise.race :wink:

https://javascript.info/promise-api#promise-race

1 Like

Thanks Thomas! That’s indeed what I should be searching for. I just got it implemented in my worker with help from your link. :slight_smile:

1 Like