Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

104
Vistas
Returned data from function is Promise (fulfilled) data
defaultValue = getFile(getCurrent.value[name]) 

Function getFile:

const getFile = async (id) => {
  const data = store.dispatch(Actions.FILE, id).then(() => {
    const data = [{ description: store.getters.currentFile.description, url: 'https://test.com/uploads/'+ store.getters.currentFile.name }]
    return data
  })
  return data
}

If I console.log(defaultValue): I see the following output; enter image description here

But I need a array instead of this Promise thing. How to solve?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You have to use await keyword on your getFile to retrieve value front promise because your getFile returns Promise.

async function yourFunc() {
   defaultValue = await getFile(getCurrent.value[name])
   // do whatever you want
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

You need to use the await keyword

const getFile = async (id) => {
   await store.dispatch(Actions.FILE, id);
   return  [{ description: store.getters.currentFile.description, url: 'https://test.com/uploads/'+ store.getters.currentFile.name }]
}

and then await the call to getFile too

defaultValue = await getFile(getCurrent.value[name]) 
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda