'Why 'user' in serve side are in different format than say maybe browser side console.log result?

in React/Nodejs App. I wish to get user.id value, but I cannot get it from frontend code, which after console.log, shows like so:

{token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZ…TMxfQ.ea2lwGVzuFebzHqWBFtCsJm-Sdt2YhuPMcclHW04tzg', username: 'root', name: 'Superuser'}

if I wish to get the value of user.id, then its undefined in my code.

On the server side, localhost:3000, user be shown like this:

{
username: "root",
name: "Superuser",
blogs: [
],
id: "6234ce14c654a312f8564fa3"
},

I am able to get user.id from server side user object with no problem.

Any idea why is it so? How can I get user.id in my frontend code. I wish to compare these two values, so give possiblity to the loggedin user to do deletion of user's data.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source