This answer looked pretty close but I think there's a fundamental difference between this answer and my problem that makes the answer insufficient for my needs.
From an ajax post, I'm getting a JSON value returned that looks like this:
{
"token": "wegHOIoi32h4gt834ygli",
"expires": "1496845449"
}
I need to save the token value wegHOIoi32h4gt834ygli
into localStorage.
Here's my code:
$.ajax(settings).done(function (response) {
console.log(response);
$(".Results").html(response);
$.each(response, function (index, element) {
var token = element.value;
console.log(token);
localStorage.setItem("token", token);
})
});
Now I'm getting this error:
Uncaught TypeError: Cannot use 'in' operator to search for '326' in {
"token": "wegHOIoi32h4gt834ygli",
"expires": 1496845449
}
Pretty sure I don't have any idea what's going on at this point. How can I extract the value I'm looking for?