Provider places doesn't return a value, although correct


#1

Hi, recreating NearMe2 locally and getting this error :

Error: $injector:undef

This is the explanation on angularjs site:

Undefined Value
Provider 'places' must return a value from $get factory method.
Description
This error results from registering a factory which does not return a value (or whose return value is undefined).

and this is the service places.js:


app.factory('places',['$http', function($http){ return $http.jasonp('https://en.wikipedia.org/w/api.php?action=query&list=geosearch&gsradius=5000&gscoord=40.741934%7C-74.004897&gslimit=30&format=json&callback=JSON_CALLBACK'). success(function(data){ return data; }). error(function(error){ return error; }); }]);

any ideas?

thanks!


#2

app.factory('places',['$http', function($http){
	return
	$http.jasonp('https://en.wikipedia.org/w/api.php?action=query&list=geosearch&gsradius=5000&gscoord=40.741934%7C-74.004897&gslimit=30&format=json&callback=JSON_CALLBACK').
		success(function(data){
			return data;
		}).
		error(function(error){
			return error;
		});
}]);

#3

unbelievable but true:
the thing that worked was to move the $http.jsonp (i noticed that type jason as well, but correcting it didn't make a difference) UP right next to the return so that:

return $http.jsonp('https://en.wikipedia.org/w/api.php?action=query&list=geosearch&gsradius=5000&gscoord=40.741934%7C-74.004897&gslimit=30&format=json&callback=JSON_CALLBACK')
		.success(function(data){
			return data;
		})
		.error(function(error){
			return error;
		});

#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.