res.cookie('jwt', "token",{
httpOnly: true,
maxAge: 1000
})
function yourXFunction(async1, async2, async3, someCallback) {
new Promise(resolv => { resolv(async1(someCallback))})
.then(() => {
return async2(someCallback);
})
.then(() => {
return async3(someCallback);
})
.then(() => {
return someCallback();
});
}
const async1 = cb => {
setTimeout(() => {
cb(1);
}, 4000);
};
const async2 = cb => {
setTimeout(() => {
cb(13);
}, 6000);
};
const async3 = cb => {
setTimeout(() => {
cb(5);
}, 3000);
};
const someCallback = val => console.log(val);
yourXFunction(async1, async2, async3, someCallback);