I did this:
const getData = async (array,s,number) => {
const response = await axios.get(s);
const theData = response.data
array[number]=theData
}
then this:
let array=[]
array.push(0)
getData(array, props.location.groupArray[i].link,0) //await axios.get(s) here returns an array of objects
console.log(array) //prints Array(1)
console.log(array[0])//prints 0
console.log(array[0].length) //prints undefined
my question is why is array[0] here 0 and not an array of objects even though when I clck on Array(1) it shows:
"0: (99) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…},"
I need array to be an array of arrays of objects, in the original code I call getData more than once with 3rd parameter 0,1,2... after I push 0 to array, my problem here is I'll only know during runtime how many axios.get I'm gonna perform thats why I wanted an array of arrays of objects