I am using an Angular service as an interface for API calls. In this case JavaScript's asynchronous nature makes this difficult. Do you have any suggestions to how I should do it?
function getOrder(orderId) {
$http({
method: 'GET',
url: '<api-url> + orderId'
}).success(function (result) {
/* --- getOrder should return parameter 'result' --- */
});
}
promise patternusing.thenfunction..do return data from it.and then the consumer method's.thenwill get called.