반응형
TypeError : 정의되지 않은 속성 'then'을 읽을 수 없습니다.
loginService.islogged()
위의 함수는 "실패"와 같은 문자열을 반환합니다. 그러나 실행하려고 할 때 작동하면 오류가 반환됩니다.
TypeError: Cannot read property 'then' of undefined
커서는 바로 뒤 connected
와 앞을 나타냅니다 .then
.
다음은 전체 기능입니다.
var connected=loginService.islogged();
alert(connected);
connected.then(function(msg){
alert("connected value is "+connected);
alert("msg.data value is "+msg.data);
if(!msg.data.account_session || loginService.islogged()=="failed")
$location.path('/login');
});
최신 정보
여기에 islogged()
기능이 있습니다
islogged:function(){
var cUid=sessionService.get('uid');
alert("in loginServce, cuid is "+cUid);
var $checkSessionServer=$http.post('data/check_session.php?cUid='+cUid);
$checkSessionServer.then(function(){
alert("session check returned!");
console.log("checkSessionServer is "+$checkSessionServer);
return $checkSessionServer;
});
}
나는 $checkSessionServer
"실패한"문자열 이 될 것이라고 확신 합니다. 더 이상은 없습니다.
약속을 호출 함수에 반환해야합니다.
islogged:function(){
var cUid=sessionService.get('uid');
alert("in loginServce, cuid is "+cUid);
var $checkSessionServer=$http.post('data/check_session.php?cUid='+cUid);
$checkSessionServer.then(function(){
alert("session check returned!");
console.log("checkSessionServer is "+$checkSessionServer);
});
return $checkSessionServer; // <-- return your promise to the calling function
}
TypeError : AngularJS를 사용하여 Django 서비스를 호출 할 때 undefined 속성 'then'을 읽을 수 없습니다.
Python 서비스를 호출하는 경우 코드는 다음과 같습니다.
this.updateTalentSupplier=function(supplierObj){
var promise = $http({
method: 'POST',
url: bbConfig.BWS+'updateTalentSupplier/',
data:supplierObj,
withCredentials: false,
contentType:'application/json',
dataType:'json'
});
return promise; //Promise is returned
}
MongoDB를 데이터베이스로 사용하고 있습니다 (중요하지 않다는 것을 알고 있습니다.하지만 누군가 MongoDB + Python (Django) + AngularJS로 검색하면 결과가 나와야합니다.
참고URL : https://stackoverflow.com/questions/24788171/typeerror-cannot-read-property-then-of-undefined
반응형
'Programing' 카테고리의 다른 글
ifstream 열기가 실패 할 때 오류 메시지를 얻는 방법 (0) | 2020.09.14 |
---|---|
Google 앱 엔진 또는 아마존 웹 서비스 (0) | 2020.09.14 |
Python : n 개의 목록을 만드는 가장 빠른 방법 (0) | 2020.09.14 |
node.js 웹앱을 일반 데스크톱 앱으로 패키징 (0) | 2020.09.14 |
CSS 선택기에서 공백은 무엇을 의미합니까? (0) | 2020.09.14 |