express query string typescript code example
Example 1: typescript req.query.query
// req.query.shopEventId is possibly === undefined
if (!req.query.shopEventId) {
return res.status(400).send()
}
const shopEventId: string = String(req.query.shopEventId)
Example 2: get query parameters in node.js
var express = require('express');
var app = express();
app.get('/', function(req, res){
res.send('id: ' + req.query.id);
});
app.listen(3000);