我有以下index.js文件:
var express = require('express');
var app = express();
app.use('/',(req,res) => {
console.log(req.get('Date'));
console.log(req.get('User-Agent'));
console.log(req.url);
var name = req.query.name;
res.status(200).type('html');
res.write('Hello World! <br>');
if (name) {
res.write('Hi, ' + name + " it's nice to see you.");
}else{
res.write('Welcome, guest!');
}
res.end();
});
app.listen(3001, () => {
console.log('Listening on port 3001');
});
为什么日期未定义?
答案 0 :(得分:1)
因为您使用的浏览器未在标题中发送日期...
您可以使用本地服务器日期....