My Node.js application uses Express.
Sending this test data from my client using jQuery POST:
{ title: 'hello', notes: [ {title: 'note 1'}, {title: 'note 2'} ]
}
And this is the result of my server code:
{ title: 'hello', notes: { '0': { title: 'note 1' }, '1': { title: 'note 2' } } }
I want an array of notes to be inserted into my database as an array. What am I missing?
How can I not add the answer myself for 8 hours (wtf?), But it doesnโt actually answer why Express.bodyParser does not parse JSON correctly.
Ok, I can get it to work using:
JSON.stringify ( data )
client side then server side using
JSON.parse( req.rawBody )
This is wrong, and why does Express.bodyParser not correctly parse JSON ?!
source share