I have the following code and I would like to execute the async functions sequentially. However, each function has different arguments. I am not sure how to cleanly achieve this unless I am using a function closure.
const funcs = [
func1(config, obj1, obj2, 1),
func2(config, obj2),
func3(config, 1),
];
for (const fn of funcs) {
try {
await fn();
} catch (error) {
console.error(error)
}
}
I was thinking of changing the array to
const funcs = [
() => func1(config, obj1, obj2, 1),
() => func2(config, obj2),
() => func3(config, 1),
];