I am new to javascript and angular .
I have created a custom service in angular which connects to a url and fetches information .I am trying to return reponse.data instead if just response
var getAlldatas = function($http)
{
var getuser= function(username){
$http.get("https://api.github.com/users/"+username).then(function(response{
return response.data;
});
};
};
however this isn't working until I add a return statement right before $https as show below
var getAlldatas = function($http)
{ var getuser= function(username){
return $http.get("https://api.github.com/users/"+username).then(function(response{
return response.data;
});
};
};
please help me to understand as to why the extra "return" statement is necessary as all i need is to return response.data from this function