SOURCE

const getJSON=function(url){
    return new Promise((resolve,reject)=>{
        if(url.includes('3')||url.includes('5')||url.includes('7')){
            resolve('done');
        }else{
            reject('not 3 5 7');
        }
    });
}
//----promise all----//
//接收一个数组作为参数,数组都是promise的实例. 只有所有的promise实例状态全部是fulfilled
//p才是fulfilled
//如果有一个实例为rejected ,p就会变为rejected. 触发reject的callback函数
const promises = [ 3, 5, 7].map(function (id) {
  return getJSON('/post/' + id + ".json");
});

Promise.all(promises).then(function(posts){
    console.log('pomise all done');
}).catch(function(reason){
    console.log('error : '+reason)
})
console 命令行工具 X clear

                    
>
console