I am new to this node.js. I am using mysql in my node.js. From the url i am constructing sql query. With 1 parameter its working fine.
The URL:
http://ipaddress:3002/users/Kappalur
By using the following code i extracted the Kappalur and its working fine:
app.get('/users/:level', function (req, res) {
connection.query("select * from levels where level4= '"+req.params.level+"'", function(err, rows, fields) {
res.writeHead(200, { 'Content-Type': 'application/json'});
res.end(JSON.stringify(rows,null,"\n"));
Now my requirement is i want to make "level4" to be dynamic..
Consider now the url be:
http://ipaddress:3002/users/level4/Kappalur
Now how can i change the above code to get the 2 parameters from url. Help me to solve this..Thanks in advance.
As I understood you are using express
framework for node.js.
To retrieve multiple URL parameters use just the same pattern as that you have used in your post's code snippet:
app.get('/users/:level/:name', function (req, res) {
var level = req.params.level;
var name = req.params.name;
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments