Javascript promise with your bare hand
Just show you how does promise work in very simple code
function firstMethod() {
console.log("shoud be called at the first time");
}
function secondMethod() {
console.log("shoud be called at the second time");
}
function thirdMethod() {
console.log("shoud be called at the third time");
}
const howPromiseWork = new Promise((resolve, reject) => {
resolve(firstMethod());
});
howPromiseWork.then(secondMethod())
.then(thirdMethod())
.catch(function(error) {
console.log(error)
throw(error);
});
// will print log
VM541:2 shoud be called at the first time
VM541:6 shoud be called at the second time
VM541:10 shoud be called at the third time