Skip to content

Commit

Permalink
Ajustes Rotas
Browse files Browse the repository at this point in the history
  • Loading branch information
GugaDavi committed Aug 8, 2019
1 parent 7c4e34f commit 9fa577f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion backend/src/controllers/DesLikeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ module.exports = {
const loggedDev = await Dev.findById(user);
const targetDev = await Dev.findById(devId);

return res.json({ loggedDev, targetDev });

if (!targetDev) {
return res.status(400).json({ error: 'Dev not Exists' });
}

loggedDev.deslikes.push(targetDev._id);
loggedDev.dislikes.push(targetDev._id);

await loggedDev.save();

Expand Down
2 changes: 1 addition & 1 deletion backend/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ const routes = Router();
routes.get('/devs', DevController.index);
routes.post('/devs', DevController.store);
routes.post('/devs/:devId/likes', LikeController.store);
routes.post('/devs/:devId/deslikes', DesLikeController.store);
routes.post('/devs/:devId/dislikes', DesLikeController.store);

module.exports = routes;

0 comments on commit 9fa577f

Please sign in to comment.