Server Side Java Script Question

I wonder if anyone on this forum has any exeriance with server side java script?

I have a situation where I need to loop through a form post using SSJS.

for example with php I would do it this way:


foreach($_POST as $key => $val){
	print($key.'<=>'.$val.'<br />');
	}

thanks

I assume you’re talking about Node.js - are you using a framework at all (Express, Geddy)?

Yes Node.js and I have been told its the version 3 of ECMA script 3. not sure about framework.

I’m afraid I can’t help you much, as I’m not an expert on node.js, but if you were using Express I believe you could do something like this:

req.body.forEach(function(element, index, array){
    // Do what you want with the POST data
});

From what I understand, doing it in plain node.js is significantly more complicated - see this link: http://blog.frankgrimm.net/2010/11/howto-access-http-message-body-post-data-in-node-js/