I’m trying to make a form with Node.js/Express and I need help! It’s a simple form that asks the user for their name and message and puts it in a database (Replit’s db).
There is no code link or Repl link because I haven’t started it yet.
I’m trying to make a form with Node.js/Express and I need help! It’s a simple form that asks the user for their name and message and puts it in a database (Replit’s db).
There is no code link or Repl link because I haven’t started it yet.
expressjs isn’t able to do forms directly (it can’t do anything client-side), although it can handle form submissions
It can if u are creative about it
What you probably want to do is receive a post request:
// automatically turn all form/json input to json
express.use(express.json());
// simple post route
app.post("/api", function(req, res) {
// print the form/json input
console.log(req.body);
});
I’m not 100% sure about form input being automatically converted to JSON, so you should test this to be sure.
Can I invite you to the Repl I’m working on so you can understand?
Sure that’s fine
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.