Post array/object with the Request module

I'm trying to make http post request using the request module

text = 'some data';

request.post('http://example.com/read', {form:{data: text}});

This works fine for a simple string, but I need to be able to send an array or object.

When I try to read the array/object in the post handler the data property is empty.

What's going here? Your help will be much appreciated.

Try this:

var request = require('request');

request({
  method: 'POST',
  uri: 'http://example.com/read',
  body: {'msg': 'secret'},
  json: true
}, function (error, response, body) {
  console.log('code: '+ response.statusCode);
  console.log(body);
})

Let me know if it works.