Question: I have two factories in my angular app.

```
app.factory('FavoritesArtists',['$http', '$q', 'UserService', function($http, $q, UserService){
    var deferred = $q.defer();
    var userId = UserService.getUser().userID;

    $http.get('http://myurl.com/something/'+userId)
    .success(function(data) {
        deferred.resolve(data);
    })
    .error(function(err) {
        deferred.reject(err);
    });

    return deferred.promise;
}]);

```

And I have a value I get from another factory :

```
var userId = UserService.getUser().userID;

```

But I doesn't update when the UserService.getUser() is changed, the view changes with $watch, but I don't know how it work inside a factory.

Any help is welcome, thanks guys !

Answer: 
Anyone ?

```
app.factory('FavoritesArtists',['$http', '$q', 'UserService', function($http, $q, UserService){
  var deferred = $q.defer();

  $http.get('https://homechefhome.fr/rise/favorites-artists.php?user_id='+userId)
  .success(function(data) {
      deferred.resolve(data);
       })
      .error(function(err) {
          deferred.reject(err);
      });

  return deferred.promise;
}]);

```

I simply need to make userId variable dynamic..
A better design pattern will be this

```
app.factory('UserService', 
['$http', function($http) {

    var getUser = function() {
        return http.get("url_to_get_user");
    };

    return {
        getUser: getUser
    };

}]);

app.factory('ArtistService', 
['$http', '$q', 'UserService', function($http, $q, UserService) {

    var getFavoriteArtists = function() {

        UserService.getUser().then(function(response) {

            var userId = response.data.userID;
            return $http.get('http://myurl.com/something/' + userId);

        }, function() {

            //passing a promise for error too
            return $q.reject("Error fetching user");

        });
    };

    return {
        getFavoriteArtists: getFavoriteArtists
    };

}]);

```

Now call it in controller like,

```
ArtistService.getFavoriteArtists().then(function(response) {

    //do something with response.data

}, function(response) {

    //log error and alert the end user

});

```