I am trying to obtain data from getAllDatas method.
This works fine without any error:
var getAlldatas = function ($http) {
var getuser = function (username) {
return $http.get("https://api.github.com/users/" + username).then(function (response) {
return response.data;
});
};
This throws error:
var getAlldatas = function ($http) {
var getuser = function (username) {
var pro = $http.get("https://api.github.com/users/" + username).then(getThis);
var getThis = function (response) {
return response.data;
};
return pro;
};
How ever i get the following error message for the second one
angular.js:10071 TypeError: Cannot read property 'protocol' of undefined
How is the second one different from first and why does this throw error?
Why don't both behave in a similar way?
var pro = ...line is actuallyvar pro = $http.get("https://api.github.com/users/" + username).then(undefined);-> Hoisting