Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7 criar transaçao #43

Merged
merged 15 commits into from
Dec 4, 2020
Merged
Prev Previous commit
Next Next commit
Terminada rota que retorna lista de transaçoes
  • Loading branch information
JongaMatos committed Dec 2, 2020
commit 24826d901d166b9da4d158bf13088166cd5c54de
17 changes: 14 additions & 3 deletions api/app/routes/controllers/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ routes.post('/',
});

routes.get('/',
async (req, res) => {
let response = null
async (req, res) => { //Devolve lista de transaçoes pelo id do usuario (userId).
try {
const list = await Transaction.findAll({ where: { userId: req.body.userId } });
console.log(list)

if (list.length > 0) {
return res.status(httpStatus.OK).json(list)
} else {
return res.status(404).json({ message: "Usuario não encontrado" })
}
} catch (err) {
//handle error
console.log("###############################################")
Expand All @@ -44,6 +48,13 @@ routes.get('/',

}
})
routes.put('/',
async (req, res) => {
try {

} catch (err) {

}
})

export default routes;