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

86
Vistas
Return value instead of promise without await

As parent function does not support async. I need to make call without await and get return value. As suggested on most of the posts, applied promise with then and returning value. But it prints as "promise" instead of return "value".

Can you please share, how to achieve return value instead of promise.

code sandbox: https://codesandbox.io/s/await-without-async-and-return-value-qbs7t?file=/src/index.js


await isEnable(data) {
  try {
    ...
    return true;
  }
  catch (e) {
    console.error(e);
  }
}
}

const getEnableStatus=(data) =>{
  return isEnable(data).then((result) =>
    {console.log(result); return result;});  //this prints correctly but, need this in return result.
}

console.log(getEnableStatus(data)); //it always print 'promise'. how to get value here instead of promise.
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Pass in a callback to the getEnableStatus function, and then call it with the returned data.

// Mock function that resolves after
// two seconds
function isEnable() {
  return new Promise((res, rej) => {
    setTimeout(() => res('Hallo!'), 2000);
  });
}

// Accept a callback, and call it with the data
function getEnableStatus(data, callback) {
  isEnable(data).then(callback);
}

// The callback logs the data
getEnableStatus('data', function (data) {
  console.log(data);
});

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