Seeking help on retrieving the result of an $http request from my controller.
Below is my service code :
.service('postService', function($http, apiUrl) {
return {
post: function(uri, params) {
$http.post(apiUrl + uri, params).then(function(items) {
return items.data;
});
}
};
})
And here is my controller implementation :
var fetchResult = postService.post('my_service_url', {id: 'test'});
fetchResult.then(function(result) {
$scope.data = result;
console.log(data);
});
Encountering an error message:
getData is undefined
Any recommendations on how to resolve this issue?