I'm trying to just send data from my React frontend to Node backend using jquery's ajax method. The api request is being received by Node, but the data is undefined.
React:
console.log("Making Node API call");
$.ajax({
method: "POST",
url: "test",
data: {
name: "John",
place: "Alaska"
}
}).done(function( msg ) {
console.log(msg);
});
Node:
app.post("/test", (req, res) => {
console.log("Request received");
console.log(req.body);
});
Node prints "Request received", followed by undefined
. It's still undefined if I log req
instead of req.body
.