I'm trying to loop over an array of objects to call an api. I destructure the return values but because I am making multiple requests I need to give them unique alias names. Is there a way to use a dynamic name for the alias like:
{data: section.id + "Data"}
const sections = [
{id: 'one', api: '/api/one'},
{id: 'two', api: '/api/two'},
];
sections.forEach((section) => {
const { data: section.id + "Data", error: section.id + "Error" } = useFetch(() =>
section.url, {
query: section.query,
});
});