Answer the question
In order to leave comments, you need to log in
How to parse object returned from mongoose?
mongoose from the back, upon request to find a user, returns an object of type [{_id:"12312313", FirstName:"dfdfdf", etc.}]. How to parse this object? Can't get regular valid json. I would be very grateful for a nod in which direction to dig.
p.c. - on the back also tried to convert - with the same zero result.
server route:
router.post('/loginUser',async function(req, res){
try{
const UserF = await User.find({"Password":(req.body.Password)})
res.json(UserF)
console.log(UserF)
} catch(err){console.log(err)}
}
)
handleSubmit(e){
e.preventDefault();
var CandidateUser = this.state
axios.post('/api/loginUser',(
CandidateUser
))
.then(res=>{console.log(res.data)
})
.catch(err=>{alert(err)})
}
[
{
_id: 60cdc1bb3ac3651ed0915a46,
FirstName: '.имя',
LastName: 'фамилия',
Created: '19.06.2021, 13:06:50',
Password: '11111111',
__v: 0
}
]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question