Whenever I try to add parameters to my route, I always encounter an error. It seems to mess up the HTML file that I serve and ends up returning a "not found" HTML file instead of the JS file that is supposed to be inside the served HTML file.
app.get('/polls',function(req,res){
res.sendFile(__dirname + "/public/poll.html")
})
The above code snippet works perfectly fine, however, when I try to add parameters like this:
app.get('/polls/:id',function(req,res){
res.sendFile(__dirname + "/public/poll.html")
})
I start encountering errors on the client side. The console displays an error on line 1 of the JavaScript file inside poll.html, but strangely shows line 1 of poll.html in the console as well. You can find the GitHub directory linked here: https://github.com/tienanh2007/Voting-App