Skip to content
Snippets Groups Projects

Movie page

Merged Bilel El Yaagoubi requested to merge movie-page into master

Files

+ 66
0
const express = require("express");
const GenreModel = require("../models/genre");
const router = express.Router();
module.exports = router;
// router.get("/popular/:number", async function (req, res) {
// try {
// const filmNumber = await req.params["number"];
// const getGenres = await GenreModel.find({})
// .sort({ popularity: "desc" })
// .limit(filmNumber);
// res.send(getGenres);
// } catch (error) {
// console.log(error);
// }
// });
router.get("/genre/id/:id", async function (req, res) {
try {
const genreId = await req.params["id"];
const getGenres = await GenreModel.findOne({ id: genreId });
res.send(getGenres.name);
} catch (error) {
console.log(error);
}
});
// router.post("/new", async function (req, res) {
// try {
// const newGenre = new GenreModel({
// // Genre attributes
// publisher: req.body.publisher,
// title: req.body.title,
// date: req.body.date,
// imageURL: req.body.imageURL,
// viewers: req.body.viewers,
// });
// // Create a new genre instance
// const createdGenre = await newGenre.save();
// // What to do after genre has been saved !
// console.log("Genre Saved");
// res.send(createdGenre);
// } catch (error) {
// console.log(error);
// }
// });
// router.put("/id/:id", async function (req, res) {
// try {
// const genreId = await req.params["id"];
// await GenreModel.findByIdAndUpdate(genreId, {
// publisher: req.body.publisher,
// title: req.body.title,
// date: req.body.date,
// imageURL: req.body.imageURL,
// viewers: req.body.viewers,
// });
// res.send("Done");
// } catch (error) {
// console.log(error);
// res.send("Invalid Id");
// }
// });
Loading