When I get on my local web browser I can see that the "request payload" is just showing me an array with two objects like this [object Object].
How can I fix this so that the "request payload" will show me the contents instead?
ex: {name: "Kevin", content: "pew pew"}
const form = document.querySelector("form");
const loadingElement = document.querySelector(".loading");
const API_URl = "http://localhost:5000/holla";
loadingElement.style.display = "none";
form.addEventListener("submit", (e) => {
e.preventDefault();
const formData = new FormData(form);
const name = formData.get("name");
const content = formData.get("content");
const holla = {
name,
content,
};
form.style.display = "none";
loadingElement.style.display = "";
fetch(API_URl, {
method: "POST",
body: holla,
headers: {
headers: {
"content-type": "application/json",
},
},
});
});
const express = require("express");
const cors = require("cors");
const app = express();
app.use(cors());
app.use(express.json());
app.get("/", (req, res) => {
res.json({
message: "Hollered at! what you gonna do about it!",
});
});
app.post("/holla", (req, res) => {
console.log(req.body);
});
app.listen(5000, () => {
console.log("listening on http://locahost:5000");
});