Sunny-117 / js-challenges

✨✨✨ Challenge your JavaScript programming limits step by step

Home Page:https://juejin.cn/column/7244788137410560055

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

并发多个请求,返回先得到response的。函数输入为url数组,输出为第一个返回的response的结果。

Sunny-117 opened this issue · comments

function main(urls:string[]) {
const promises= urls.map((url)=>axios.get(url))
return Promise.race(promises)
}