Quick question about passing data between files

In node.js I can use modules.export to pass things to other files in the backend, what is the equivalent in vanilla js?

for example: What if I wanted to prompt the user with client-side javascript then store that data from the prompt into an object. How do I pass that object to the back-end?

(not using a post request from the markup)

If you want to pass something to the back-end you can use a post request using AJAX. You could stringify the object.

fetch(youURL, {
  method: 'post',
  body: JSON.stringify(yourObject)
  .then(res => console.log(res));

Oh, perfect that’s exactly what I was looking to understand thank you!