I can't figure out why this problem is arising. When I make an ajax post request in my javascript file, the url gets called, but the data wont get sent. Here's how I make a post request:
<script type="text/javascript">
    $.ajax({
        type: "POST",
        url: "/test",
        dataType: "json",
        data: {test: "test"},
        contentType: "application/x-www-form-urlencoded",
    });
</script>
And on my backend, here's the post method I'm using:
app.post('/test', function(req, res) {
  console.log(req.body); // returns {}
  console.log(req.params); // returns {}
});
Here's what I tried so far: XMLHttpRequest to Post HTML Form, AJAX Post not sending form data , Send POST data using XMLHttpRequest but unfortunately none of them worked for me.
 
     
    