Sending data from the front-end to the back-end

Hello all, I am in the process of building my first full stack application and wanted to know the best way to see what I am passing to the back-end. Just to be clear on what I am asking, I am trying to log the data that I send from the front-end in my command line. I want to be able to see whatever snippet of code that I sent in the request instead of seeing all the information about the request.

I am using HTML, CSS, Javascript, Express.js and mysql for this full stack application.

Below I have provided the code used on the front-end for the request as well as the server-side code.

Client-side code

function sendMessage(){
const message = document.getElementById("message");

let xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function(){
 if(this.readyState ===4 && this.status === 200){
   document.getElementById("message").innerText = this.responseText;


The Server-side Code

const express = require("express");

const mysql = require("mysql");

//const bodyParser = require("body-parser");

//activates express

const app = express();

//incorporates body parser into our app so we can read json data sent from the front end

const urlencodedParser = bodyParser.urlencoded({ extended: false })
const jsonParser = bodyParser.json();

//creates a port for the server to listen to on the front end

const port = 2400;

app.listen(2400, function () {

  console.log(`Server started on port ${port}`);


//testing a simple POST method made by some front-end javascript code"/example", function (req, res) {



I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.


Thank you for editing my post for readability.

Do you know anything that can be of help to me in regards to my question?

I am not sure what you mean…what is wrong with your current method? That is what I normally do.

If the element just has too much content, slice it.