Promise syntax

PHOTO EMBED

Wed Aug 09 2023 21:49:01 GMT+0000 (Coordinated Universal Time)

Saved by @thecowsays #react.js

const whereIsMyCoffeeOrder = function(orderId) {
  return new Promise((resolve, reject) => {
    coffeeApi.checkStatus(orderId, (error, coffeeStatus) => {
      if (error) {
        // Promise fails
        reject(error)
      } else {
        // Promise is fulfilled
        resolve(coffeeStatus)
      }
    })
  })
}
content_copyCOPY

https://youtu.be/li7FzDHYZpc?t=84