Reputation: 72
I need to use the data from quote_number parameter to create a query from this url:
http://localhost:3000/#/quote/line/?quote_number=1003
where quote_number = ${req.params.quote_number}
I'm expecting to get 1003
from this, but am getting line
as the return parameter
Upvotes: 0
Views: 126
Reputation: 49
The URL is not correct. Because you have the # symbol, Nothing is recognized after that. I don't know if you're doing it because there's no additional code.
If you try like this:
app.get('/quote/line/:id', (req, res) =>{
console.log(req.params);
});
URL in browser:
http://localhost:3000/quote/line/quote_number=1003
result:
{ quote_number: 'quote_number=1003' }
if you use query
instead of params
:
app.get('/quote/line/', (req, res) =>{
console.log(req.query);
});
in browser:
http://localhost:3000/quote/line/?quote_number=1003
result:
{ quote_number: '1003' }
and now, you can get the value by
req.query.quote_number
References:
req.query and req.param in ExpressJS
Upvotes: 1