Last active
June 20, 2019 17:44
-
-
Save beaucarnes/6cca9d24744c8cbcdabf84d212c83515 to your computer and use it in GitHub Desktop.
This file contains hidden or 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; | |
let list = []; | |
app.get('/', (req, res) => { | |
res.json(list); | |
}); | |
app.post('/add/:item', (req, res) => { | |
list.push(req.params.item); | |
res.json("Added " + req.params.item); | |
}); | |
app.get('/:index', (req, res) => { | |
res.json(list[req.params.index]) | |
}); | |
app.delete('/:index', (req, res) => { | |
const item = list.splice(req.params.index, 1); | |
res.json("Deleted " + item); | |
}); | |
app.post('/:index/:item', (req, res) => { | |
list[req.params.index] = req.params.item; | |
res.json("Updated " + req.params.item); | |
}); | |
app.listen(port, () => console.log("Review server listening on port " + port)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment