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

194
Vistas
How to solve the async operation in js

I want following output ["a","b"] out of loop but isnot getting. How can I do it? instead of getting [].

post_with_medias(text, medias) {
    var listOfIds = []
    medias.forEach((element) => {
      this.upload_media(element).then((res) => {
        // we can assign alt text to the media, for use by screen readers and
        // other text-based presentations and interpreters
        var a = res.data
   
        listOfIds.push(a) // returns ["a","b"]
      })
      
      console.log(a); // this doesnot give the data appended returns []

    })
about 4 years ago · Juan Pablo Isaza
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