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

108
Vistas
JS Data in asynchronous request undefined

In this asynchronous function console.log(m) will return correct data, whereas console.log(m.w) will return "undefined" What's wrong? I'll be very appreciative of the clues. I've tested it with just w:10, h10 so the problem is not in the server return.

var http = require('http');
var sizeOf = require('image-size');

async function asynchronousProcess(options){
    let m ={}
    await http.get(options, function (response) {
        var chunks = [];
        response.on('data', function (chunk) {
          chunks.push(chunk);
        }).on('end', function() {
          var buffer = Buffer.concat(chunks);
          var data = {w: sizeOf(buffer).width, h: sizeOf(buffer).height}
          Object.assign(m, data)
        });
    });
    console.log(m)
    return m
}
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