0
I have the following code:
app.controller("LoginCtrl", function ($scope, LoginAPI) {
$scope.doLogin = function (model) {
if (model.username === undefined || model.password === undefined) {
return false;
}
LoginAPI.post(model).success(function (results) {
localStorage.removeItem('token');
//Armazena o token no localStorage
localStorage.setItem('token', JSON.stringify(results));
//pegando so o token
console.log(results);
})
.error(function (Error) {
console.log(Error);
})
};
});
the Results variable returns me the following information:
{**"access_token":"RBIuaO8f4xsSrEUgWoPA8w1EcuRW2U1vSIGiIzzCzsPwCibo1SHRtIYWZVfpFQmW17nzJ-hQsIE4wJBZpTfZi4_OYg1EMrCyEJwWg7nN4mq7-tGwKF8cDhMlruxKBa_lVzpoUBtSB1l0UfEXwb8a-PIsWJ6LGu7uG525xLy-5stVLdrbe3nh54iygNwdyY14GlBjbrBmnWxYzRJ_5UnA7klIk-DpW3vybll24RVMgD-nR1EI-ckdRPana-nySYsYNgElwq7PSQrSr2NHavZmyo-8vMT_BcGYYF5h9dWSZoSbaE8t8II2DaM2sZL-9KLS50SMBZ1N6oPsUv2D7uI3f1qM8EsK5GQ21tG-Lt3_DHwofE_aIKvmHo2CmFTd910HBSJpR63iwMwL-9VTOT6r98u85YWP6WZxGJWJFoMmY4ek0AEjDqbvn1QQOvGBlnJzJ4wfJtqBeEt_RAIubvmg-2tS4JMaAMC-oNz904dIk_3j1RzVfjQL9CtS8eYJNcjY"**,"token_type":"bearer","expires_in":1209599,"userName":"[email protected]",".issued":"Mon, 13 Mar 2017 18:11:11 GMT",".expires":"Mon, 27 Mar 2017 18:11:11 GMT"}
I need to turn this string set into an object and take the value of the token that is the access_token that is bold. How do I solve this problem?