I have a NodeJS app that displays some tables from a database. The view engine is ExpressJS.
On the app I have a dropdown list where u can select the table you want to display. The problem is that any given table that I want to display is only accessible through the dropdown, but what I'm trying to do is make them work through URLs.
So for example when u enter an address like: http://localhost:6789/tableOne, I want the table one to be displayed. But if I load table two from the dropdown, and after that I enter the address I mentioned above, the page displays also table two, so basically is not refreshing with the new data. This makes the app working only through the interface, but I want to share to somebody else the direct link to a table and I can't. (they will receive the last table that was loaded on the app)
To rephrase, take as example an app that displays on the page the route's name. Mine doesn't update.
The routes are dynamically generated and here's an example of the routing that I did:
app.get('/someTables/:' + getNameFromID(selectedID), (req, res) => {
var url = req.url;
for (i in endData) {
if (i.name == url.substr(10)) {
selectedID = i.id;
}
}
res.render('index', { frontData2: endData2, frontData: endData, jsonToDisplayFrontEnd: jsonToDisplay, m1: m1, m21: m21, m22: m22, m1FrontEnd: m1ToDisplay, m21FrontEnd: m21ToDisplay, m22FrontEnd: m22ToDisplay, versionToDisplayFrontEnd: versionToDisplay, titleName: getNameFromID(selectedID), folderPath: getFolderPath(selectedID), folderPath2: getFolderPath2(selectedID) });
});
The function getNameFromID() returns a string.
How can I make this work? Thank you!