Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

121
Visualizações
spreading an array returned from an async function results in empty array?

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.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda