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

183
Vistas
Async/await - cannot reach promise result

I am trying to reach the Promise result in a Reactjs function component, but it does not work for me. When I return the function result I only get Promise. My goal is to return an object contained in [[Promise Result]].

const params = ['ACT', 'STBY', 'STBYH'];
const getActStby = async address => {
  const getActStbyParams = await getXhr({
    url: `./scripts/system_read_config?${xhrParam(address, params)}`
  });
  return getActStbyParams;
};

Then I call It later in a code and assigning to the object as a new property:

newItemEqpt.isAct = getActStby(getNetworkAddress(item.from.FROM, item.to.TO));

Output of these activities is "partially" okay. When I console.log the object, Promise is fulfilled, but what I wanted to is assigning the array of parameters in [[Promise result]] directly to isAct property. How can I do this?

isAct: Promise
 [[Prototype]]: Promise
 [[PromiseState]]: "fulfilled"
 [[PromiseResult]]: Object
   parameters: (3) [{…}, {…}, {…}]
   [[Prototype]]: Object
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The function getActStby declared as async, so you have to await for getting its results like so;

newItemEqpt.isAct = await getActStby(getNetworkAddress(item.from.FROM, item.to.TO));

To be able to use the await keyword like above, the function call to getActStby should also be made in an async function, otherwise you will have to chain the function with a then method and access the return value of that function by using a callback.

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