我正在使用nodejs http库。我在控制台上看到两个日志。为什么?我采用字段Elapsed time is 0.378693 seconds.
Elapsed time is 0.378163 seconds.
Elapsed time is 0.380865 seconds.
Elapsed time is 0.378316 seconds.
Elapsed time is 0.377940 seconds.
Elapsed time is 0.379100 seconds.
Elapsed time is 0.378394 seconds.
Elapsed time is 0.383894 seconds.
Elapsed time is 0.397466 seconds.
Elapsed time is 0.415835 seconds.
结果:一个日志。
response.end(JSON.stringify({'asd': 'asd'}));
答案 0 :(得分:0)
如果您从网络浏览器访问服务器,则会看到两个控制台日志,因为浏览器还会向/favicon.ico
发送请求,以检查您的网站是否提供了要显示的图标浏览器标签。
将您的控制台日志替换为console.log('req.url: ' + req.url);
以查看。