- Update the way to use the data records on Vuex with Getters!

- Fix: mongodb call passing array todos and categiroes already splitted
This commit is contained in:
Paolo Arena
2019-02-27 02:59:02 +01:00
parent d78de1a25c
commit 8f1ee2a7da
5 changed files with 107 additions and 16 deletions

View File

@@ -105,6 +105,7 @@ router.patch('/:id', authenticate, (req, res) => {
router.get('/:userId', authenticate, (req, res) => {
var userId = req.params.userId;
// var category = req.params.category;
tools.mylog('GET : ', req.params);
@@ -118,11 +119,13 @@ router.get('/:userId', authenticate, (req, res) => {
}
// Extract all the todos of the userId only
Todo.findAllByUserId(userId).then((todos) => {
// Todo.findAllByUserIdAndCat(userId, category).then((todos) => {
Todo.getAllTodo(userId).then((objtodos) => {
tools.mylog('todos', todos.length);
tools.mylog('todos', objtodos.arrtodos.length);
tools.mylog('categories', objtodos.arrcategories.length);
res.send({ todos: todos });
res.send({ todos: objtodos.arrtodos, categories: objtodos.arrcategories });
}).catch((e) => {
console.log(e);
res.status(400).send(e);