Last active
November 28, 2019 08:16
-
-
Save angelique-w/0eda86c3c0f0d33ab19c546046ad67dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
const port = 3000; | |
app.get('/api/movies', (req, res) => { | |
res.send('Récupération de tous les films') | |
}) | |
app.get('/api/movies/:id', (req, res) => { | |
const idMovie = req.params.id; | |
res.json({id: idMovie}) | |
}) | |
app.get("/api/employee", (req, res) => { | |
const name = req.query.name; | |
res.status(404).send(`Impossible de récupérer l'employé ${name}`) | |
}) | |
app.get("/api/employee/", (req, res) => { | |
res.sendStatus(304); | |
}) | |
app.listen(port, (err) => { | |
if (err) { | |
throw new Error('Sometthing bad happened...'); | |
} | |
console.log(`Server is listening on ${port}`); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment