Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

55
Views
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;
};
7 months ago ยท Juan Pablo Isaza
Answer question
Find remote jobs