Hi, I wrote the following code as part of a course., and I have a question about the array syntax below:
export async function parallel() {
setText("");
await Promise.all([
(async () => {
const data = await axios.get("http://localhost:3000/orderStatuses");
appendText(JSON.stringify(data));
})(),
(async () => {
const data = await axios.get("http://localhost:3000/orders");
appendText(JSON.stringify(data));
})(),
]);
}
My question is simple - why is there a () at the end of each array element? I see that I am passing in an anonymous async function for each element... but it's not clear to me why I also need the () after it. I am guessing the () makes the whole array element a function as well, but why this is required isn't clear to me. Thanks