getAllDatas
メソッドからデータを取得しようとしています。
これは、エラーなしで正常に動作します:私は二番目の
angular.js:10071 TypeError: Cannot read property 'protocol' of undefined
ために、次のエラーメッセージが表示されますどのように、これまで
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;
};
方法である:これはエラーがスロー
var getAlldatas = function ($http) {
var getuser = function (username) {
return $http.get("https://api.github.com/users/" + username).then(function (response) {
return response.data;
});
};
最初のものとは異なる2番目のものと、なぜこのエラーをスローしますか?
なぜ両方が同じように動作しないのですか?
var getuser = function (username) {
var pro, getThis;
pro = $http.get("https://api.github.com/users/" + username).then(getThis);
getThis = function (response) {
return response.data;
};
return pro;
};
そしてgetThis
に
'VARプロ= ...'行が、実際には 'VARプロ= $ http.get(「https://api.github.com/ (ホイット)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/var#var_hoisting) – Andreas