JSFiddle - React, Tailwind, and code Playground

by Abdul Ahmad

JavaScript

function asynchronous(val) {
	return new Promise((res, rej) => {
  	setTimeout(() => {
    	res(val || 'promise resolved');
    }, 2000);
  });
}

function TestThens() {
	const promise = asynchronous('one').then(() => asynchronous('two')).then(r => {
  	return asynchronous('three');
  });
  
  console.log('promise', promise);
}

TestThens();