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

175
Visualizações
Async function returning Promise after await

My async function below is always returning a Promise instead of waiting to resolve. I'm fairly new to async function and could use some help figuring out whats going on. I had to obfuscate the names of some functions and data in the function.

const getWebId = async (num) => {
  const startTime = Date.now();
  const args = {
    request: {
      num,
    },
  };

  let response;

  try {
    const soapClient = await createClient();
    response = await soapClient.<SOAP CALL HERE>(args);
    if (!response[0]?.webid) {
      throw new Error('Could not return a web ID');
    }
  } catch (error) {
    console.log({ message: 'Error making service call: ', error: error.message });
    return Promise.reject(error);
  }

  console.log({ message: 'Time to call service', callTime: Date.now() - startTime });
  return response[0].webid;
};
about 4 years ago · Juan Pablo Isaza
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