Skip to content

Instantly share code, notes, and snippets.

@byverdu
Last active May 31, 2017 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save byverdu/a350f8c7e5d09026f652e7c9462758d2 to your computer and use it in GitHub Desktop.
Save byverdu/a350f8c7e5d09026f652e7c9462758d2 to your computer and use it in GitHub Desktop.
// API, server side
router.get( '/api/all/:imdb', ( req, res ) => {
// req.params.imdb === 'movie' || 'series'
Imdb.find({ type: req.params.imdb })
.exec()
.then(( response ) => {
res.type( 'json' );
res.json( response );
});
});
// Angular service
getAPIData( type ) {
return $http({
method: 'GET',
url: `./api/all/${type}`
});
}
// Angular controller
service.getAPIData( $routeParams.collection )
.then( response => $imdb.collection = response );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment