How To validate Phone number field based on Lookup API JSON response?

Hello there,
I want to validate phone number field based on Lookup Api JSON response. I have used the below code but this is not working. Anyone can help me to work it?

window.ub.form.customValidators.usPhoneNumber = {
    isValid: function(value) {
    var country_code;
    var uName="API Key SID";
    var passwrd="API Key Secret";
    var apiUrl = ''+value;
    var auth = btoa(uName+":"+passwrd);
    type: 'GET',
    url: apiUrl,
    headers: {
      "Authorization": "Basic " + auth
    success : function(data) {
      country_code = data.country_code;
  return country_code === 'US';
message: 'Please enter a valid US Phone Number',
window.ub.form.validationRules.cellphone_number.usPhoneNumber = true;