title: typescript promise Rest Api
body: <p>I has the following codes which registerCustomer function will call registerCustomerApi to get data from Rest Api. I want to add in promise in order to wait for rest api return response before it return to front-end. May I know how can I add in promise?</p>
  
  <pre><code>export const registerCustomer = functions.https.onRequest(async (request, response) =&gt; {
    try {
      //Consume api to validate whether is valid customer
  
      var result = registerCustomerApi(request.body.CompanyId, request.body.DateOfBirth, request.body.MobileNo);
  
      if (result != null) {
        response.send(result);
      }
      else {
        response.send(request.body);
      }
  
    }
    catch (error) {
      console.error(error);
    }
  })
  
  function registerCustomerApi(companyId: String, dateOfBirth: String, mobileNo: String) {
    try {
      request.get(`http://localhost:57580/api/aes_brand/customer/validate_customer/SG01/1990-01-01/8299687`)
        .then(function (response) {
          return response;
        })
        .catch(function (err) {
          console.error(err);
        });
    }
    catch (error) {
      console.error(error);
    }
  }
  </code></pre>