I am a beginner and working on existing code, making few changes to post payload.
I am making a get call inside a factory like this,
var providerUrl = "/" + OPENMRS_CONTEXT_PATH + "/ws/rest/v1/session";
\$http.get(providerUrl).then(function(response){
var uuid =response.data.user.uuid;
console.log(uuid);  //1st console.log
}, function(error){
console.log(error);
});
console.log(uuid); //2nd console.log
Now the 2nd log doesn't actually shows anything probably because of the asynchronous nature.
I need to use this UUID value in the factory itself. Because I am posting a payload using $http post call like this from the same factory,
  var json = {
          patient: patient,
          uuid: ....   //HERE GOES THE GET RESPONSE
          encounterType: window.constantConfigObj.encounterTypeVisitNote,
          visit: visitId,
          encounterDatetime: date2
  };
If someone can explain me how this can be done, it would be really helpful. Thanks
 
    