0

This is a basic registration form. script.js performs input checking. express.js sends and receives data from mongodb.

What I need to do is send input values (such as username.value) after input checking from script.js to express.js. How do I do it?

things to keep in mind this is an assignment and I cannot use jQuery, React etc. just HTML, CSS, JS, Express and mongodb

VLAZ
  • 26,331
  • 9
  • 49
  • 67
Sam
  • 55
  • 6

1 Answers1

0

You could use the fetch API to do a POST request and capture it with express.

The FormData API works well for getting the data out of a form.

Example:

fetch(/* POST endpoint */, {
    body: new FormData(/* form element */),
    method: 'POST'
});
Dr. Vortex
  • 505
  • 1
  • 3
  • 16