How to disable async behaviour of RestClient


While developing business console gadgets, we have noticed that, “_this.$scope.restClient” invoke() method is calling the webservices in async mode. How can we change this to sync mode ?.

Any help would be much appreciated.

Thansk and Regards,

You should use promises to logically make it synchronous,

Can you try something like this in your js function where you are using restClient to invoke an API,

var deferred = $q.defer();

    				   _this.$ = response;
                              deferred.reject({ message: "Something went wrong" });


return deferred.promise;

here, “deferred” is a promise

1 Like

Dear Yashwanth ,

Could you please provide me sample for injecting the “$q” to controller. I tried the following way to inject $q, but it doesn’t work.

Tracker_7DF40093_EFFE_1036_BE32_1_Controller.$inject = [’$scope’, ‘RestServiceProvider’, ‘EventBus’, ‘$log’, ‘config’,‘SharedService’,’$q’];

Thanks and Regards,