Faire des promesses

new Promise((resolve, reject) => {
  if (ok) { resolve(result) }
  else { reject(error) }
})
 
Motionless Mallard