0

I have an endpoint like this:

app.post('/sendCode', async (req, res) => {
  const { code } = req.body;
});

And url like this:

http://localhost:3000/sendCode?code=ABCDEFG%##HIJKLMNOPRS

So when I enter this link in the browser I will trigger the endpoint. This works. However my code taken from req.body cuts out the second part of the code. So in my endpoint I see only ABCDEFG% part, the second is cut off. How can I get whole ABCDEFG%##HIJKLMNOPRS?

Murakami
  • 3,474
  • 7
  • 35
  • 89
  • 3
    Does this answer your question? [get url after "#" in express.js middleware request](https://stackoverflow.com/questions/17744003/get-url-after-in-express-js-middleware-request) – Milan Velebit Feb 13 '20 at 09:02
  • From your url `http://localhost:3000/sendCode?code=ABCDEFG%##HIJKLMNOPRS`, it's looks like `req.query`, not `req.body`. – Titus Sutio Fanpula Feb 13 '20 at 09:02

1 Answers1

0

The browser won't send the part of the URL that starts with hash # symbol. The information that follows the hash (URL fragment) is intended for Javascript code executed by the client.

More on this topic here: Can I read the hash portion of the URL on my server-side application (PHP, Ruby, Python, etc.)?

Tomasz
  • 657
  • 3
  • 9