使用 Express 和 node.js 在响应中发送换行符

Bre*_*dan 6 newline response line-breaks node.js express

我正在尝试使用 Express 发送带有换行符的字符串。

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

persons = [//...];

app.get('/info', (req,res) => {
    res.send(`Phonebook has info for ${persons.length} people.
    ${Date()}`);
});
Run Code Online (Sandbox Code Playgroud)

我在网上读到,从 ES6 开始,反引号可用于构造多行,但它似乎不起作用。

我想要的输出是:

Phonebook has info for 4 people.

Thu Oct 10 2019 18:54:01 GMT-0700 (Pacific Daylight Time)
Run Code Online (Sandbox Code Playgroud)

我还尝试了以下方法:

app.get('/info', (req,res) => {
    res.send(`Phonebook has info for ${persons.length} people.\n${Date()}`);
});

Run Code Online (Sandbox Code Playgroud)

我在网上读到你也可以只使用 '\n' 但这也不起作用。

我究竟做错了什么?我一直在遵循我在网上找到的建议,但我无法显示新的一行。

Bre*_*dan 12

解决方案是使用<br/>标签而不是 \n,因为我的 res.send() 的目的是将 HTML 发送到我的本地浏览器。感谢@Jason。