basir / next-amazona

next-amazona.vercel.app
289 stars 226 forks source link

Unhandled Runtime Error SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data #8

Open Awais512 opened 2 years ago

Awais512 commented 2 years ago

}, 12 | userInfo: Cookies.get('userInfo')

13 | ? JSON.parse(Cookies.get('userInfo')) | ^ 14 | : null,

Giving error in the store here. I don't know whats the problem is Screenshot 2021-11-23 at 19-26-41 Amazona

Here is the screenshot above

MohammadSahabuddin commented 2 years ago

}, 12 | userInfo: Cookies.get('userInfo')

13 | ? JSON.parse(Cookies.get('userInfo')) | ^ 14 | : null,

Giving error in the store here. I don't know whats the problem is Screenshot 2021-11-23 at 19-26-41 Amazona

Here is the screenshot above

just in Store.js add JSON.stringify

like::

userInfo: Cookies.get('userInfo') ? JSON.parse(JSON.stringify(Cookies.get('userInfo'))) : null,

back2basic commented 2 years ago

Cookies.set('userInfo', JSON.stringify(data)); In your login.js fixes the issue. You have to convert the object to string so it can be stored properly