Skip to content
Snippets Groups Projects
Commit d4376e8a authored by Bilel El Yaagoubi's avatar Bilel El Yaagoubi
Browse files

continue TP

parent 01d117cd
No related branches found
No related tags found
1 merge request!5Draft: Front bilel
Pipeline #42459 passed
......@@ -4,8 +4,13 @@ const router = express.Router();
module.exports = router;
router.get("/", function (req, res) {
res.send("Hello world");
router.get("/", async function (req, res) {
try {
const getMovies = await MovieModel.find({});
res.send(getMovies);
} catch (error) {
console.log(error);
}
});
router.post("/new", async function (req, res) {
......@@ -28,3 +33,19 @@ router.post("/new", async function (req, res) {
console.log(error);
}
});
router.put("/id/:id", async function (req, res) {
try {
const movieId = await req.params["id"];
await MovieModel.findByIdAndUpdate(movieId, {
publisher: req.body.publisher,
title: req.body.title,
date: req.body.date,
imageURL: req.body.imageURL,
});
res.send("Done");
} catch (error) {
console.log(error);
res.send("Invalid Id");
}
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment