-1

I am trying to read multiple inputs from URL (may vary with every request) in NODEJS.

For eg: www.blahblah.com/api/abc/xyz/pop/god/ is requested,

I want to take 'abc','xyz','pop','god' and process each individually. the script i am passing it to, takes the input and passes it to a perl script to get the output.

I am using AngularJS and NodeJS.

any suggetions.

1 Answers1

0

I'll say. Make the ajax call with Json Data

$.ajax({
  type : "POST",
  url : "/yourServiceUrl",
  data :{
    data1 : data1Val,
    data2: data2Val,
    .
    .
    .
    datan: datanVal
  }
}).done((result)=>{});

Fetch the data in backed using

let data1 = req.body.data1;
let data2 = req.body.data2;
.
.
.
.
let datan = req.body.datan;

Regular expressions may also be used, and can be useful if you have very specific restraints, for example the following would match "GET /commits/71dbb9c" as well as "GET /commits/71dbb9c..4c084f9".

app.get(/^\/commits\/(\w+)(?:\.\.(\w+))?$/, function(req, res){
  var from = req.params[0];
  var to = req.params[1] || 'HEAD';
  res.send('commit range ' + from + '..' + to);
});

This should solve your problem :)

Prasanta Bose
  • 674
  • 5
  • 13