Angularjs $ cookieStore SyntaxError: JSON.parse: unexpected character

Do you have any idea why I get an error message

SyntaxError: JSON.parse: unexpected character

in this code

console.log($cookieStore.get('XSRF-TOKEN'));

cookie value

kscJcqrDYSMdZtBleuq8yUrB

?

UPDATE NODE CODE

var currentSession = req.session.passport;
var user = currentSession.user;
res.cookie('USER',JSON.stringify(user) , { maxAge: 900000, httpOnly: false});
+4
source share
1 answer

$ cookieStore is a serialized session store. This gives you an error because the cookie value is not serialized.

You need $ cookies for your value.

+10
source

Source: https://habr.com/ru/post/1532339/


All Articles