I have this route /new/:url
. Now, when I make request like /new/https://www.google.com
, I get Cannot GET /new/https://www.google.com
as the response. What I expect is to get the string https://www.google.com
. I read this answer URL component encoding in Node.js about encoding the URL but how will I be able to do so when a GET
request is made to the route /new/:url
? Here is my code for that route
app.get('/new/:url',(req,res) => {
const url = encodeURIComponent(req.params.url);
console.log(url);
res.json({
url
});
});