首页  >  问答  >  正文

显示数据库数据的方法:使用console.log(req)

<p>我运行了<code>console.log(req);</code>来查看其中的内容,并发现来自数据库的数据与会话数据一起显示出来</p> <pre class="brush:js;toolbar:false;">sessionStore: MySQLStore { . . . options: { host: 'localhost', user: 'root', password: '1324', database: 'dbso', endConnectionOnClose: true, clearExpired: true, checkExpirationInterval: 900000, expiration: 86400000, createDatabaseTable: true, connectionLimit: 1, charset: 'utf8mb4_bin', schema: [Object] }, . . . </pre> <p>我正在使用<code>express-mysql-session</code>和<code>express-session</code></p> <pre class="brush:js;toolbar:false;">app.use(session({ secret: "sss", resave: false, saveUninitialized: false, store: new mySQLStore({ /*数据库信息*/ }) })); </pre> <p>我关心和怀疑的是我应该对此担心多少,如果我需要担心,我该如何解决它?</p> <p>我们的网站使用cookie来存储用户会话。</p> <p>我的疑问总结是,req是否可以在用户端被查看/获取到?</p>
P粉396248578P粉396248578389 天前406

全部回复(2)我来回复

  • P粉639667504

    P粉6396675042023-09-01 00:54:03

    看起来你正在从Node进程中调用console.log。除非你做了非常奇怪的事情(例如通过http将这个req对象发送回客户端),否则客户端不会看到这个。

    回复
    0
  • P粉704066087

    P粉7040660872023-09-01 00:18:56

    编号

    请求对象用于在中间件和终点处理程序之间传递数据。它只在服务器上可见。

    回复
    0
  • 取消回复