Skip to content

Tag: promise

Chain of Promises Example

const f1 = async() => {
    setTimeout( () => {
        console.log("f1");
    }, 100)
};

const f2 = async() => {
    setTimeout( () => {
        console.log("f2");
    }, 100)
};

const f3 = async() => {
    return new Promise((resolve, reject) => {
        reject("f3");
    });
};

const f4 = async() => {
    setTimeout( () => {
        console.log("f4");
    }, 100)
};

const workflow = async () => {
    await f1();
    await f2();
    await f3();
    await f4();
};

workflow().catch((error)=>{
    console.error(error);
})