Huligan Huligan - 1 year ago 95
Node.js Question

How to transfer params to GET method in Express?

I have the following URL:

'http://localhost/track/' + id + '/fromdate/' + date_start + '/todate/' + date_end

And there is handler in Node.js part:

app.get('/track/:id/fromdate/:fromdate/todate/:todate', function(req, res){

Why I can not get

Answer Source

can you try this please:

'http://localhost/track/' + encodeURIComponent(id) + '/fromdate/' + encodeURIComponent(date_start)+ '/todate/' + encodeURIComponent(date_end)

when you are making a get request, you should turn the parameters into encoded URI components like in the example i give

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download