I have a function loadData which attemps to fetch an array of customers. I wonder what is the best way to extract the data "outside"? Right now the only solution I can think of is using an external array and injecting it with data. I do not know however if this is the best practice as the test array is getting mutated in the process. What could an alternative solution be?
const test = [];
const loadData = (async () => {
const customersFetched = await fetch(customers);
const data = await customersFetched.json();
test.push(data);
})();