I have a service to call an API as follows:
getValue: function(input) { var deferred, url; deferred = $q.defer(); url = "url"; $http.post(url, input).success(function(data, status, headers, config) { return deferred.resolve({ success: true, data: data, status: status, headers: headers, config: config }); }).error(function(data, status, headers, config) { return deferred.resolve({ success: false, data: data, status: status, headers: headers, config: config }); }); return deferred.promise; }
But it is asynchronous. How can I convert it to synchronization (I want to make it wait until I get the result)?
source share