在 POST 请求 NodeJS Express 服务器中,您在哪里看到 console.log 语句?

Where do you see console.log statements inside a POST request NodeJS express server?

我在 NodeJS 中有一个快速服务器。它有一个 POST 请求,其中包含 console.logs。我在哪里可以找到 console.logs?

const express = require('express');
const cors = require('cors');
const app = express();

app.use(cors());
app.use(express.json());

const PORT = 5000;

app.get('/', (req, res) => {
    console.log("this appears in the browser");
});

app.post('/login', (req, res) => {
    console.log("where do I see this text??");
});

app.listen(PORT, '0.0.0.0', function() {
    console.log("Server started (this text appears in the terminal)");
});

我是 运行 命令提示符的服务器。 console.logs 不在请求中的内容出现在其中。 POST请求函数中的console.logs出现在哪里?我问是因为我想看看更复杂的 POST 请求中的逻辑是怎么回事。

当您直接从 cmd 运行 Node.js 服务器时,它应该启动服务器并监听指定的端口。现在,当你开始点击 route/s 所有 console.log o/p 到终端 window 而不是浏览器控制台 window。查看图片以供参考。

它将出现在您将服务器置于 运行 的同一终端中。