Promises

new Promise((resolve, reject) => {
  // do some async stuff						
  // call resolve(value) to make the Promise succeed
  // call reject(reason) to make the Promise fail	 
});

then()

Chaining then()

catch()

promiseFunction("print")
  .then(res => res)
  .then(res => res)
  .then(() => console.log(“anonymous function text”))
  .catch(reason => console.err("Badness happened", 		reason));

Promise.all()

async

await

Refactoring a Promise chain from .then to await
function wrapper() {
  promise1
    .then(res1 => {
      console.log(res1);
      return promise2;
    })
    .then(res2 => {
      console.log(res2);
      return promise3;
    })
    .then(res3 => {
      console.log(res3);
    });
}

with async/await…

async function wrapper() {
  console.log(await promise1);
  console.log(await promise2);
  console.log(await promise3);
  console.log(await promise4);
}

fetch

const fetch = require('node-fetch');

const MOVIE_API_KEY = "some-api-key";

const url = `https://omdbapi.com/?apikey=${MOVE_API_KEY}&t=fight+club`

fetch(url)
    .then(res => res.json())
    .then(json => console.log(json.Actors))
    .catch(reason => console.log('rejected because', reason))