I know this topic was mentioned here and here but it didn't work for me.
I'm trying to get parameters from URL using req.query
. In my server.js
file I've got this:
app.get('/reset-pass', function(req,res) {
console.log(req.url);
console.log(req.query);
})
When I'm entering URL e.g. http://localhost:3000/reset-pass?email=anything
, server console outputs this:
/reset-pass
[Object: null prototype] {}
and when I fetch from http://localhost:4001/reset-pass
, browser console outputs empty object:
data {
"query": {}
}
As you can see I run my node server on 4001
port and client site on 3000
(because I'm running React on that port) and it's working well doing POST
requests or redirects, but in GET
case it doesn't return query params. Any weird #
do not appear in my path (or I just don't know it).
What's wrong with it?