Hi I have a url of format
> http://127.0.0.1:3000/sss?AP=API&SE=AU
I used to follow the below code to query
var data=req.query[AP]
But now my url is
> http://127.0.0.1:3000/sss/API/AU
I am stuck as how to query this data.Any help regarding this will be much helpful.
try
var parse = require('connect').utils.parseUrl;
var pathname = parse(req).pathname;
var data = pathname.split('/');
// data[2] => API
// data[3] => AU
or
var parse = require('connect').utils.parseUrl;
var pathname = parse(req).pathname;
var data = pathname.match(/\/sss\/(\w+)\/(\w+)/)
if (data) {
// data[1] => API
// data[2] => AU
}
What you could do is using the routing of express.
With something like this, you'll get your values directly in the req.params object:
var app = require('express').express();
app.get( "/sss/:AP/:SE", function( req, res ) {
console.log( req.params.AP, req.params.SE );
});
Best regards Robert