Your browser doesn’t natively format JSON responses like you’re showing in your example. If you want to format the JSON response in your browser, the browser extension JSON Formatter can be installed into your browser. This will detect JSON/JSONP and display it for you formatted.
Example with the extension installed:
All this extension does is make the JSON response easier to read, it doesn’t change the content type or data returned. Making a request to /test
will work with or without the extension.
As a side-note, your code can be simplified to use express’s .json()
method:
const express = require ("express");
const app = express();
app.get("/test", async(req, res) => {
const rows = await actiondb();
res.json(rows);
});
CLICK HERE to find out more related problems solutions.