Skip to content
Snippets Groups Projects
Commit 0de98881 authored by julien.debray's avatar julien.debray
Browse files

Prototype OK

parent 13fdee6a
No related branches found
No related tags found
No related merge requests found
const express = require('express')
const bodyParser = require('body-parser');
const app = express()
const port = 3001
let rdv = [{"idMagasin":1,"idClient":1,"date":"2019-01-01","heure":"12:00:00"}];
app.use(bodyParser.json());
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.post('/prendre-rdv', (req, res) => {
console.log(req.body)
rdv.push({idMagasin: req.body.idMagasin, idClient: req.body.idClient, date: req.body.date, heure: req.body.heure})
res.status(200).send('ok');
})
app.get('/liste-rdv', (req, res) => {
res.send(rdv);
})
app.get('/liste-rdv/:id', (req, res) => {
res.send(rdv[req.params.id - 1]);
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
\ No newline at end of file
{
"name": "myapp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.18.2"
}
}
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "start": "node app.js"
}, },
"author": "", "author": "",
"license": "ISC", "license": "ISC",
......
File moved
{
"idMagasin": 1,
"idClient": 1,
"date": "2019-01-01",
"heure": "12:00:00"
}
\ No newline at end of file
{
"idMagasin": 1,
"idClient": 1,
"date": "2019-01-01",
"heure": "12:00:00"
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment