Instead of returning Promise object i am getting resolved value. How does it happen?

Viewed 38

i was going through Promise workflow then figured out something which left me confused while using await with Promise response..

function GetAllListofEmployees()
{
  const promise = new Promise(function(resolve, reject){
    Url = 'api/GetEmployees';
    ServiceInstance.GetCall(Url).then(function (result){
      //from result Load Data to global variable;
      resolve("Yes");  
  })  
})
}

async function ShowEmployees()
{
   var promise = await GetAllListofEmployees();// this line is returning me 'Yes' instead of   
                                               // a promise object, without applying '.then' 
                                               // function and call resolve function to get  
                                               // the value.
   if(promise == "Yes") 
   {
     // i can access this block causing result is "Yes".
   }

}

0 Answers
Related