Skip to content

Instantly share code, notes, and snippets.

@dengjonathan
Created October 15, 2016 19:09
Show Gist options
  • Save dengjonathan/873bca905e4214cbfe429bf101dcf234 to your computer and use it in GitHub Desktop.
Save dengjonathan/873bca905e4214cbfe429bf101dcf234 to your computer and use it in GitHub Desktop.
Angular Factory wrong way
angular.module('shortly.services', [])
// use of arrow functions seems to break the Angular API
.factory('Links', ($http) => {
const addOne = url => $http({
method: 'POST',
url: '/api/links',
data: {
url: url
}
});
const getAll = () => $http({
method: 'GET',
url: '/api/links'
})
.then(res => {
return res.data;
});
return {
addOne,
getAll
};
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment