Skip to content
Advertisement

How can i get input data from a form in node.js?

Working on a weather application in node.js But when i tried to get the input value through document.getElementById to show weather about a specific location it is showing error i have a file in my views folder where i provide JavaScript file using script tag but even then I am getting error.

error is given below:

GET http://localhost:3000/js/JavaScript.js net::ERR_ABORTED 404 (Not Found)

Advertisement

Answer

It is due to the fact that you are not serving a static files in your nodejs server. If you are using express server in your application you have to give the below code in main server js file app.use(express.static('public')) here public means the folder where you have html, js folder, css folder

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement