I am writing a factory in angular that uses two sets of data. I need one set of data to equal a variable so I can pass that in another API call. For some reason my variable always returns the whole function instead of just returning the variables. All environment variables are available.

```
var zones = function(){
            var deferred = $q.defer();
            $resource(ENV.web_api_url + ENV.api_version + '/zones/:zoneId', {}, {
                query: {
                    method: 'GET',
                    cache: false,
                    params: {zoneId: '@zoneId', date: $filter('date')(new Date(), "yyyy-MM-dd")},
                    isArray: true,
                    headers: {
                        "X-Auth-Token": $window.sessionStorage.token
                    }
                }
            }).success(function(data){
                deferred.resolve(data);
            }).error(function(){
                deferred.reject('There was an error')
            });
            return deferred.promise;
        };

```