我试图将数据从 Drupal 页面发送到节点
Drupal 代码
function sample_submit($form, &$form_state) { //Function to connect with node and save into Mongo using node
$jsonData = check_plain($form_state['values']['jsonData']);
$request_url = "http://10.20.5.112:3000/save";
$options = array(
'method' => 'POST',
'data' => $jsonData,
'timeout' => 15,
'headers' => array('Content-Type' => 'application/x-www-form-urlencoded'),
);
$result = drupal_http_request($request_url, $options);
}
节点.js
app.post('/save', function(req, res){ //Rest Api Function to get data from pushed by drupal
//console.log(req.data);
res.send('Success');
});
如何获取从drupal发送的数据作为node.js中的jsondata