Skip to content

Commit

Permalink
fix: catchErrors doit être mis sur toutes les routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud AMBROSELLI committed Jul 10, 2024
1 parent 04350cc commit 16e4e57
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions api/src/controllers/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ const fetch = require("node-fetch");
const { DataFrame } = require("data-forge");
const { METABASE_ACCOUNT, METABASE_PASSWORD } = require("../config");

router.get("/metabase", async (req, res) => {
try {
router.get(
"/metabase",
catchErrors(async (req, res) => {
const questionIndex = req.query.question;
const sessionResponse = await fetch("https://metabase-ozensemble.fabrique.social.gouv.fr/api/session", {
method: "POST",
Expand Down Expand Up @@ -55,10 +56,7 @@ router.get("/metabase", async (req, res) => {
const df = new DataFrame(rows);

res.status(200).json({ result: df.toJSON() });
} catch (error) {
console.error(error);
res.status(500).json({ error: "Internal Server Error" });
}
});
})
);

module.exports = router;

0 comments on commit 16e4e57

Please sign in to comment.