The Query String - abbernie/web-dev-sp17 GitHub Wiki
Express gives you access to any data that comes in through the query string in the URL. You've seen examples of the query string in some of the external APIs we used. For example, the Instagram API uses the query string in its URL to set the client id and the latitude/longitude in a location search: https://api.instagram.com/v1/media/search?lat=48.858844&lng=2.294351&client_id=abc123abc12345
.
The URL mysite.com/info/person?city=Brooklyn&name=Jim&school=NYU
would provide the variables city
,name
, and school
as request.query.city
, request.query.name
, and request.query.school
.
// url is http://yourdomain/profile?id=485 (for example)
app.get('/profile', function(req, res){
res.send('id: ' + req.query.id);
});