Skip to content

Instantly share code, notes, and snippets.

@byverdu
Last active May 30, 2017 22:55
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/8fcc07200456d4c9481135d33255d973 to your computer and use it in GitHub Desktop.
Save byverdu/8fcc07200456d4c9481135d33255d973 to your computer and use it in GitHub Desktop.
// app/client/js/services/imdbService.js
module.exports = function ( $http ) {
return {
getImdbData( name, type ) {
return $http({
method: 'POST',
url: `./api/search?q=${name}&t=${type}`
});
},
addItem( data ) {
return $http({
method: 'POST',
url: './api/add',
data
});
},
getAPIData( type ) {
return $http({
method: 'GET',
url: `./api/all/${type}`
});
},
deleteItem( id ) {
return $http({
method: 'DELETE',
url: `./api/delete/${id}`,
data: id
});
},
updateItem( id, rating ) {
return $http({
method: 'PUT',
url: `./api/update/${id}`,
data: {
rating
}
});
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment