Vishal Vishal - 1 year ago 99
Javascript Question

Provider 'xx' must return a value from $get factory method

Here is my angular service:

.factory('partyService', function($http) {
this.fetch = function() {
return $http.get('/api/parties')
.then(function(response) {

I think this service is returning data (or an empty array // not sure)

Then why am I geeting this error:

Error: [$injector:undef] Provider 'partyService' must return a value from $get factory method.


If I use service instead of factory then I don't get any errors. Why so???

Answer Source

The error speaks for itself. You must return something in your factory:

var factory = {
  fetch: fetch

return factory;

function fetch() {

Then, in your controller:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download