req.query
is a request object that is populated by request query strings that are found in a URL. These query strings are in key-value form. They start after the
var express = require('express');var app = express();const PORT = 3000;app.listen(PORT, ()=>{console.log("app running on port "+PORT);})
app.get("/user", (req, res)=>{var name = req.query.name;var isAuthor = req.query.isAuthor;res.json({name,isAuthor})})
/user?name=Theodore&isAuthor=true"
.{
"name": "Theodore",
"isAuthor": "true"
}
Thanks for reading!