URL shortener project ( solved)

Tell us what’s happening:

  1. req.params is undefined but res.params has the value that I want to obtain. This is really weird. I used app.get(‘path’, callback function). For more details, you can check my repl.

  2. The connection to mongodb is on but new url and shortened pairs cannot be seen in mongodb.

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36.

Challenge: URL shortener

Link to the challenge:

Hello there,

This line has an error/typo:

const { id_string } = res.params;

Hope this helps

Hi, I know I should use req.params but it doesn’t work. So it’s very weird that I can only get the result from res.params. That’s my question

Ah right. Well, try adding a ? to the end of your parameter.

I just realised, you have switched the parameters req, res

Hope that helps

Yes, you’re right. I didn’t realise it. Thank you!