I use several external database sto get the data I need to create the record I want in my database. I have an application where users can search and add a movie to their watchlist.
For this I need the following data,
- The movie data such as title, release date, and id.
- The imdb rating.
- The movie credits such as actors and directors.
This is how I do it now,
movieAdd.add(movie.id).then(function(response){
$scope.movieListID = response;
movieAdd.imdbRating($scope.movieListID.imdb_id).then(function(response){
$scope.movieImdbRating = response;
movieAdd.crew(movie.id).then(function(response){
$scope.movieCredits = response
return createMovie.create({
id: $scope.movieListID.id,
imdb_rating: $scope.movieImdbRating.imdbRating,
title: $scope.movieListID.original_title,
image: $scope.movieListID.poster_path,
movie_id: $scope.movieListID.id,
backdrop: $scope.movieListID.backdrop_path,
overview: $scope.movieCredits.overview
})
})
})
})
I call a service, return the store the response in a scope so I can use it later on, and so on.
Is this the correct way of doing this, or is there a better way?