I wanna make a form to send to node.js something like:
{
name: "John Snow",
email: "john.snow@got.hbo.com",
phones: [
{number: "1xx123345567", type: "Home"}, // Winterfell
{number: "1xx897654651", type: "Work"} // the wall
]
}
I try
form
input(name="name")
input(name="email")
input(name="phones[0].number")
input(name="phones[0].type")
input(name="phones[1].number")
input(name="phones[1].type")
No success :/
Create a JSON object for your array using JSON.stringify().
var userObj = {
name: "John Snow",
email: "john.snow@got.hbo.com",
phones: [
{number: "1xx123345567", type: "Home"}, // Winterfell
{number: "1xx897654651", type: "Work"} // the wall
]
}
var jsonUserObj = JSON.stringify(user);
Then you write this object to the http request you use for posting the data.
Detailed explanation here - http://tech.pro/tutorial/1091/posting-json-data-with-nodejs