I am building login and registration form in NextJS and MongoDB. Users can sign up and then login. I created a profile page. On profile page I want to display user information: name, email, created date.
If I am using substring()
method I am getting:
TypeError: Cannot read properties of undefined (reading 'substring')
I was trying slice()
method and the same typeError:
as above. Can you tell me why and how to fix it? Thank you.
const [born, setBorn] = useState(user?.user?.createdAt)
console.log(born) // 2023-05-20T04:12:43.952Z
I would like to get 2023-05-20
This is my solution:
const created = born.substring(0,10)
console.log(created) // 2023-05-20 here is all good BUT!
If I put created to the body. I am getting error as I mentioned above.
<p>Created: {created}</p> // TypeError: Cannot read...