sessionStorage不替代

时间:2019-03-19 09:51:45

标签: angularjs

$scope.admin_email;
$scope.admin_password;
$scope.onSelect = function(admin_email,admin_password){
    console.log( admin_email,admin_password)
  console.log("User Name: ", $scope.admin_email, 
              "Password : ", $scope.admin_password);
    var mydata = {
      admin_email : $scope.admin_email,
      admin_password : $scope.admin_password
    }
    $http({
      async: true,
        method: 'POST',
        url: 'http://localhost:3000/api/v1/users/login',            
        data : mydata
    }).then(function successCallback(response){       
    if(response.status==200){
      console.log({response});
      $rootScope.isLogged=true;

      setTimeout(function(){
      window.sessionStorage.accessToken = response.data.token;
    }, 1000)

      $("#loginModal").modal("hide");
    //  console.log($("#loginModal"));
    setTimeout(function(){
      window.location='#/dashboard'
    }, 1000)


    }
    else{
      alert('login password or username incorrect')
    }
    },
    function errorCallback (response) {            
        alert("some error occurred. Check the console.");
        console.log(response);
    });
}

此代码window.sessionStorage.accessToken = response.data.token;不起作用,它是这里的登录api window.sessionStorage.accessToken没有替换

  1. 列表项

显示此类错误

  

对象ata:空错误:true消息:代码:“ invalid_token”内部:expiredAt:“ 2019-03-19T09:22:27.000Z”消息:“ jwt已过期”名称:“ TokenExpiredError”原型:对象消息: jwt过期”名称:“ UnauthorizedError”状态:​​401原型:对象状态:500原型:对象

0 个答案:

没有答案