title: How to make a $http request from the rest client in AngularJs?
body: <p>Have this scenario when I make a request via $http in the first service, and then I want to manipulate the data in other service. For some reassons my returned object is empty. Any advice ? </p>
  
  <pre><code>.factory('widgetRestService',['$http','$log',function($http,$log){
  
    var serviceInstance = {};
    serviceInstance.getInfo = function(){
      var request = $http({method: 'GET', url: '/rest/widgets/getListInfoDashboards'})
        .then(function(success){
          serviceInstance.widgets = success.data;
          $log.debug('serviceInstance.widgets SUCCESS',serviceInstance.widgets);
        },function(error){
          $log.debug('Error ', error);
          $log.debug('serviceInstance.widgets ERROR',serviceInstance.widgets);
        });
      return request;
    };
  
    serviceInstance.getAllWidgets = function () {
      if (serviceInstance.widgets) {
        return serviceInstance.widgets;
      } else {
        return [];
      }
    };
  
    return serviceInstance;
  
  }])
  
  .factory('OtherService',['widgetRestService','$log', function(widgetRestService, $log){
  
     widgetRestService.getInfo();
  
     // and now I want to return widgetRestService.widgets [{things},{things},{things}]
    return widgetRestService.getAllWidgets(); // returns []
  
   }])
  </code></pre>
  
  <blockquote>
    <p>Result: [ ]</p>
  </blockquote>