Created
October 15, 2016 19:09
-
-
Save dengjonathan/873bca905e4214cbfe429bf101dcf234 to your computer and use it in GitHub Desktop.
Angular Factory wrong way
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
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