In the route.js file, I have implemented the following REST method:
app.get('/api/todos', isAuthenticated, function(req, res) {
DB.TodoTable.find()
.exec(function(err, todos) {
res.json(todos, function(err){
if (err) console.log(err);
}); // return all todos in JSON format
console.dir(res);
});
});
Upon debugging, it was discovered that the 'res' object's 'statusCode' field contains unexpected data. This could be the reason why the data is not being received on the angular side.
{
...
statusCode:
[ { index: Mon Jan 19 2015 09:33:54 GMT+0530 (India Standard Time),
text: 'hello',
_id: 23ffs2sdfsdd64c0834534,
__v: 0 } ]
}
In controller.js, there is another method:
Todos.get()
.success(function(data) {
console.info("Data received from server:");
console.dir(data);
});
However, in this case, 'data' is returned as an empty string. This issue seemed to arise after integrating passport.js.
Is passport.js causing this problem? If not, what steps can be taken to resolve this issue?