Skip to content

Instantly share code, notes, and snippets.

@angelique-w
Last active November 28, 2019 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelique-w/0eda86c3c0f0d33ab19c546046ad67dc to your computer and use it in GitHub Desktop.
Save angelique-w/0eda86c3c0f0d33ab19c546046ad67dc to your computer and use it in GitHub Desktop.
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