Currently, I have a website that utilizes Express to serve pages. It is functioning properly with a form that uses a POST query to load the page with data in an ajax-style manner.
However, I am now looking to make the page and its contents bookmarkable by converting it to use GET instead. But I am encountering an issue:
When I use the GET form after loading the root page, filling out the form, and submitting it, everything works as expected. However, if I try to access the page using a bookmark, all I see is the object displayed as plain text.
I understand the reason behind this behavior, but I am unsure of how to properly address and resolve it. It seems like I cannot send both the index.html file and the object simultaneously.
This is a snippet of my server code:
app.get("/", function (request, response) {
response.sendFile(__dirname + '/views/index.html');
});
app.post("/formpg", main);
app.get("/formpg", main);
function main(request, response) {
var params = request.query;
// * here goes the magic *
response.send({data: magic});
}