I am attempting set a constant to an array of objects which is returned from an async function. When I log the constant, the result is as expected:
code:
const songList = songsArrayFromIdList(rehearsal.rehearsallist);
console.log(songList);
logs (as expected):
[]
0: {formtake: 'https://...
1: {userpracticed: 'do...
2: {formtake: 'https://yo...
3: {titleabbreviation: 'DPM', formtake: 'https...
length: 4
[[Prototype]]: Array(0)
However, I'd like to spread the returned array of objects into the constant in order to in create a new array reference (to later include in a React state object). But, when I spread the returned array into the constant it logs an empty array:
const songList = [...songsArrayFromIdList(rehearsal.rehearsallist)];
console.log(songList);
logs (unexpectedly):
[]
length: 0
[[Prototype]]: Array(0)
very frustrated. I feel like the obvious issue has something to do with the array returning from an async function. But, clearly the array is usable due it logging properly when not spread??
What am I missing?
Thanks in advance.