M
M
marataziat2018-02-14 11:11:03
Node.js
marataziat, 2018-02-14 11:11:03

How to use in express req, I have a problem with routes?

Here is what I have:

app.get('/register/:realfirstname/:realsecondname/:username/:password', function (req, res) {
  // Add validation
  console.log(req.realfirstname)

console.log(req.realfirstname) - prints undefined :(, this is how I send the request:
Here is the whole code:
app.get('/register/:realfirstname/:realsecondname/:username/:password', function (req, res) {
  // Add validation
  console.log(req.realfirstname)
  // Normal registration
  MongoClient.connect(url, function(err, db) {
    var dbo = db.db("test");
    dbo.collection("userslist").insertOne({ realfirstname: req.realfirstname, realsecondname: req.realsecondname, username: req.username, password: req.password, sessionid: null, sessiontime: null }, () => {
      db.close();
    });
    res.send("User registred");
  });
})
app.listen(3000)

localhost:3000/register/Ashot/Tryboshat/marataziat...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RidgeA, 2018-02-14
@marataziat

0. I recommend reading the documentation
1. I do not recommend passing passwords in the query string

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question