TypeError: Cannot read property 'then' of undefined

后端 未结 2 1285
长情又很酷
长情又很酷 2020-11-29 02:53
loginService.islogged() 

Above function return a string like \"failed\". However, when I try to run then function on it, it will return error of

2条回答
  •  执念已碎
    2020-11-29 03:11

    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
    }
    

提交回复
热议问题