Today’s TIL: You can use app.route()
for handling both GET and POST requests on the exact same endpoint in Express:
Just chain them together after using app.route('/endpoint')
like so…
app.route('/things')
.get(function (req, res) { res.send('Get a thing') })
.post(function (req, res) { res.send('Add a thing') })
.put(function (req, res) { res.send('Update a thing') })
Keepin’ it clean…