title: how can i access variables in different javascript functions on the same factory?
body: <p>im trying to build an instagram feed app with ionic framework and i created a factory to handle my html requests so i can use them on my controllers, thing is, with instagram API, theres a value on the json array called next_url that i need to load the Older Photos/posts so:
  This is my factory:</p>
  
  <pre><code>app.factory('PersonService', function($http){
  var BASE_URL = "https://api.instagram.com/v1/tags/sometag/media/recent?access_token=+++";
  var items = [];
  var nextUrl = 0;
  
  return {
    GetFeed: function(){
    return $http.get(BASE_URL+'&amp;count=10').then(function(response){
      items = response.data.data;
      **nextUrl = response.data.pagination.next_url;**
  
      return items;
  
    });
  },
  GetNewPhotos: function(){
    return $http.get(BASE_URL+'&amp;count=2').then(function(response){
      items = response.data.data;
  
      return items;
    });
  },
  GetOldPhotos: function(){
    return $http.get(**nextUrl**).then(function(response){
      items = response.data.data;
      return items;
    });
  }
  }
  });
  </code></pre>
  
  <p>I want to use the <strong>nextUrl = response.data.pagination.next_url;</strong> from GetFeed function to get the next_url and use it on the GetOldPhotos function that will use the nextUrl to load the older photos, i dont think i can return 2 values from the same function and i think $scope isnt an option in factory.</p>
  
  <p>I know there could be more than one way to achieve this but i just started with ionic, angular, and javascript and im realy stuck here and would be great if i could get some "guidance" :D
  Sorry for any grammar, syntax, or any other error in this post and thank you in advance!</p>