Sending menu selection to MongoDB

Hi everyone,

I have a menu that looks like this, the yellow selection apperas around each DIV as it’s selected:


And here is the HTML:

This website is currently running as a server with Node.js and Node is connected to a MongoDB database.

I have a hard time figuring out how to interact with the database from the webpage. In this case, I have three different DIVs that I have attached eventListeners to. How can I move the selected menu information (in this example, “Easy: 1 word”) to node so that I can insert it into the database? Do I have to use forms with POST requests everytime I want to send information or how can I approach this? In this case it’s not a traditional form so I would like to easily send the information to the node.js back-end.

I am completely new to binding this many techniques (HTML, JS, Node, MongoDB) together so feel free to give any advice you want to as I really want to learn best-practices in this field.

I managed to solve this by using the “fetch” function in JS. With that I can generate post and get requests without using forms. For some reason it was extremely hard to find any examples on the Internet without using HTML forms. Everyone shows that and then stops at that.