I have a simple express app that gets one fetch request, the fetch looks like this:
let opts = {
method: "POST",
headers: {
"Content-Type": "application/json",
},
mode: "no-cors",
body: {
"test": "test"
}
}
fetch("http://localhost:3001/data", opts)
and it's in the setup() function.
the serverside code looks like this:
const express = require('express');
const app = express();
app.listen(3001, () => console.log("listening at 3001"));
app.use(express.static("public"));
app.use(express.json());
app.post("/data", (req, res) => {
console.log("post recived");
console.log(req.body);
});
in my console what I get after refreshing everything is this:
listening at 3001
post recived
{}
the body of the post is not undefined but it is empty, I cannot figure out what the problem is for the life of me