1

I am new to creating servers with node. My application needs to get input from front end (by html input fields) and to write that to server.js file with simple (button 'onclick') function that I had created in a file called script.js. A script.js file and that function are exported to server.js, but cannot be used cause node.js cannot support DOM. In my server.js file, I have allready imported fs, filePath, http and express modules. Then, I've made a simple server that can be used to read content(fs.readFile()), but not to write it (fs.writeFile()) - as I want. In node command prompt, I'm getting errors like 'input field undefined', 'document.getElementById undefined', etc...

So, what can I do to write json file with values (strings) that are collected from html input fields/tags?

Milosh
  • 49
  • 6
  • Please share your server and client side code. – Bhuneshwer Nov 14 '19 at 13:06
  • can you please share the code so it will make it more clear – ALOK VERMA Nov 14 '19 at 13:06
  • I could share it, but it would be better for me just to pick up advice on writing json file with input values which are taken with javascript function from html input tags. – Milosh Nov 14 '19 at 13:15
  • The software you run in the browser and the software you run in Node.js are **different programs** and don't have access to each other's variables even though they are written in the same programming language. – Quentin Nov 14 '19 at 13:34

0 Answers0