search

Home  >  Q&A  >  body text

node.js - app.use的参数,get不到

不知道怎么表达,反正就是报错了

黄舟黄舟2783 days ago371

reply all(4)I'll reply

  • 怪我咯

    怪我咯2017-04-17 15:30:45

    Obviously your username is not defined
    Try adding an if judgment to your second middleware

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 15:30:45

    Just take it directly when you use it,

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 15:30:45

    The two usernames are in different scopes, of course they are undefined...

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 15:30:45

    These are the variables of two methods. The second one cannot refer to the username in the first method. Use req.session.username again and get it once.

    reply
    0
  • Cancelreply