TypeError: Cannot read property 'then' of undefined TypeError: Cannot read property 'then' of undefined angularjs angularjs

TypeError: Cannot read property 'then' of undefined


You need to return your promise to the calling function.

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: Cannot read property 'then' of undefined when calling a Django service using AngularJS.

If you are calling a Python service, the code will look like below:

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 }

We are using MongoDB as the database(I know it doesn't matter. But if someone is searching with MongoDB + Python (Django) + AngularJS the result should come.