ShortUrl making no progress getting req.body.url form form

Tell us what’s happening:
req.body.url has an empty value, and none of the fixes I’ve researched are helping solve. I’ve tried body-parser, but that seems to be deprecated, so I’ve tried express.urlencode() as well as expres.json() both give no relief. Geting ready to quit.

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36

Challenge: URL Shortener Microservice

Link to the challenge:

It’s impossible to say without code. Post a link to a live version of the project, like on repl.it, and maybe someone can help.

You can always log the route inputs at the start of a route to see what’s there:

console.log(`body:  ${req.body}`);
console.log(`params:  ${req.params}`);
console.log(`query:  ${req.query}`);

which is helpful if you’re like me and forget what you and express have agreed to put where.

1 Like

deleted because of links to code

Yikes! I just figured it out! I was fooled by the placeholder text in the form input field. I assumed it would be substituted for the value. I was wrong! The reason req.body.url was an empty string was because I did not type anything into the text field! Now I can go back to square one and work on this from scratch.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.