HwangJaeYoung HwangJaeYoung - 1 year ago 59
Ajax Question

Don't read the JSON Object in node.js

I have some problem to get json object...

I send a json object to localhost(node.js server).

When node.js server received the json object, parsed json object has 'undefined

For that reason, I checked the json object but it has not structure problem..

How can I solve this problem?

Thank in advance!

url: "",
type: "post",
dataType: "text",
cache: false,
timeout: 30000,
data: JSON.stringify(jsonObject),
success: function (data) {
error: function (xhr, textStatus, errorThrown) {
alert(textStatus + ' : ' + errorThrown);


app.post('/saveResource', function (request, response) {

var resultObj = request.body;
var object = resultObj.requestInfo;
console.log(typeof(object)); -> 'undefined' type


* node.js server reveceive the following object.

"requestInfo": {
"urlInformation": "data",
"methodInformation": "GET",
"bodyInformation": "data",
"headerInformation": []

Answer Source

@jeremy-thille already answered the question, but to be more clear just change

dataType: "text"


dataType: "json"

And remove the JSON.stringify call....