I'm using expressJS in a nodeJS server. In one part of my site, I need to response with a HTML page and a JSON. The page is a form, and with the JSON i want to fill the form, so the user can change something and save.
If I use response.json(user)
, I can get and see the json, but I don't know how to send both (html page of the form and json to fill data).
app.use(express.static('public'));
app.use(express.json());
...
...
app.get('/finish', (request, response) => {
let user = JSON.stringify(request.user);
//return html page (form.html in my puclic folder) and 'user' json
}
And if I send, how can I read the JSON with a script tag in html? Have a easy way to do this?