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
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Adiciona retorno para criaçao de transaçao
  • Loading branch information
JongaMatos committed Dec 1, 2020
commit d56b6880a70636bba174745186d6f1dfa007be4a
3 changes: 2 additions & 1 deletion api/app/routes/controllers/cadastro.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ routes.post('/',

} catch (err) {
// handle error
onsole.log("###############################################")
console.log(err)
console.log(AAAAAAA)
console.log("###############################################")
}
return res.status(httpStatus.OK).json(response);
});
Expand Down
21 changes: 21 additions & 0 deletions api/app/routes/controllers/transação.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,28 @@ import { user as UserEntity } from '../../models/index';
import transaction from '../../models/index';

const routes = express.Router();
routes.post('/',
async (req, res) => {
let response = null;
try {
// logics
const check = await UserEntity.findOne({ where: { id: req.body.userId } })
if (check) {
response = await transactions.create(req.body)
return res.status(httpStatus.OK).json(response);
} else {
return res.status(401).json({message:'Login e tente novamente'})
}

} catch (err) {
//handle error
console.log("###############################################")
console.log(err)
console.log("###############################################")

}

});


export default routes;