I'm storing data fetched from mongodb through nodejs in a variable like this
axios.post('http://localhost:5000/Users/login',user)
.then(res=>{
Userdata=res.data.users
console.log(Userdata)
console.log(Userdata._id)
})
But I'm unable to access the data in variable in render function here:
if(this.state.loggedin){
return <Redirect to={`/UI/Navbar/Dashboard/${Userdata._id}`}/>
}
it gives me this error:
TypeError: Cannot read property '_id' of undefined