I'm making a post request to a route i set up using express:
todolists.post('/getTodoLists', (req, res) => {
TodoList.findOne({
userEmail: req.body.userEmail
})
.then(todolist => {
if (!todolist) {
res.status(404).send()
} else {
res.status(200).json(todolist)
}
})
.catch(err => {
console.log(err)
res.status(500).send(err)
})
})
When i use the following code to retrieve data from the database, all i get in my console is 'object Object'
axios
.post('todo-lists/getTodoLists', {
userEmail: this.userEmail
})
.then(res => {
console.log('response from gettodoLists' + res)
this.todolist = res
console.log(this.todolist)
})
.catch(err => {
console.log(err)
})
When i use Postman to make a request to the same route with the same request data i get all of the data that i expect to recieve.
Thanks in advance!
EDIT:
This is what i get from Postman
{
"_id": "5caca1498accb128c8974d56",
"title": "todolist1",
"userEmail": "test@gmail.com",
"todos": [
{
"_id": "5caca1498accb128c8974d57",
"description": "Get this done",
"completed": true
}
],
"dateDue": "2019-04-07T18:24:31.207Z",
"__v": 0
}
This is what i get in my console when i console log the response
response from gettodoLists[object Object]