Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

185
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda