当前位置:网站首页>Promise (III)

Promise (III)

2022-04-23 17:03:00 Endless cake

How to use Promise?

        //all Requests made are successful only if they are all successful , There is a failure , All failed ( Return all request results Promise Array of )
        const pAll = Promise.all([p1, p2, p3])
        pAll.then(
            values => {
                console.log('all onResolved', values)
            },
            reason => {
                console.log('all onRejected', reason)
            }
        )

        // Take the result of the first completed request . The first request to complete is success , Otherwise, it will be a failure ( Only return one Promise)
        const pRace = Promise.race([p1, p2, p3])

版权声明
本文为[Endless cake]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230554519691.html