I want to see on page all text that is saved in database, but i want it to be like a list of text example
- That the first text from data base
- Here is the second one.
I try like this:
app.get('/readtext', async (req, res) => {
try {
const document = await client.query("SELECT text FROM document");
let variable = document.rows.map(row => row.text).join("n");
res.send(variable);
} catch (error) {
console.log(error);
}
});
and my output is:
That the first text from data base Here is the second one.
i went it to be like this
That the first text from data base
- Here is the second one.
with or wihtout "*" the ideea is any line from database be on a new line
i use node.js
2
Answers
On a web page you need to use br tag instead of just n:
The easier way would be to just send an array where each element is the text of each row. In your code that would be:
Of course you will need to make tha right adjustments to the front end.