let isReject = false
let promise = new Promise((resolve, reject) => {
  console.log('here we go')
  if (isReject) {
    resolve('hello')
  } else {
    reject(isReject)
  }
})

promise.then((val) => {
  console.log(val, ' World')
}).catch(val => {
  console.log(val)
})

let p1 = new Promise((resolve, reject) => {
  let error = 'error P1'
  resolve('I am p1')
  reject(error)
})

let p2 = new Promise((resolve, reject) => {
  let error = 'error P2'
  resolve('I am p2')
  reject(error)
})

let p3 = new Promise((resolve, reject) => {
  let error = 'error P3'
  resolve('I am p3')
  reject(error)
})

Promise.all([p1, p2, p3]).then(all => {
  console.log(all)
}).catch(err => {
  console.log(err)
})
