Returns the first resolved promise from the list.
const getAnyItem = async (itemId1, itemId2) => {
return Promise.race([
fetch(`https://jsonplaceholder.typicode.com/albums/${itemId1}`),
fetch(`https://jsonplaceholder.typicode.com/albums/${itemId2}`),
]).then((item) => {
// ...
});
};
getAnyItem(2, 5);
Thanks for reading π
Follow @codedrops.tech for daily posts.
Instagram β Twitter β Facebook
Micro-Learning β Web Development β Javascript β MERN stack β Javascript
codedrops.tech
Top comments (1)
poggers, this is useful as heck xD