Skip to content

Instantly share code, notes, and snippets.

@blangue
Last active June 21, 2022 20:27
Show Gist options
  • Save blangue/f3531664d11e30c15d79ddc256305b48 to your computer and use it in GitHub Desktop.
Save blangue/f3531664d11e30c15d79ddc256305b48 to your computer and use it in GitHub Desktop.
Basic Express query managment
let express = require('express');
var bodyParser = require("body-parser");
let app = express();
app.use(bodyParser.urlencoded({extended : false}));
app.post('/name', (req,res,next)=>{
res.json({name: req.body.first +" "+ req.body.last});
next();
});
app.get(
"/now",
(req, res, next) => {
req.time = new Date().toString();
next();
},
(req, res) => {
res.send({
time: req.time
});
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment