Last active
May 31, 2017 23:39
-
-
Save byverdu/a350f8c7e5d09026f652e7c9462758d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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