Why Is My Req.body Always Empty On Post?
There are many questions that are the same, with answers, but most answers I have found revolve around the use of body-parser, which I am using. I have written many basic APIs and
Solution 1:
If you set your
xmlhttp.setRequestHeader("Content-type", "application/json");
then you need to use
JSON.stringify(...your object ...)
as @JaromandaX said. if you set your
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
then you need to serialize
your object
by object.serialize();
.
Post a Comment for "Why Is My Req.body Always Empty On Post?"