I am working with the POSTMAN extension on chrome and am trying to send a request to send phantomjs. I managed to send an email request to the phantomjs script server, installing the postman, as in the attached screenshot
My script phantoms are as follows:
var server = require('webserver').create();
var port = require('system').env.PORT || 7788;
console.log("Start Application");
console.log("Listen port " + port);
server.listen(port, function(request, response) {
console.log("request method: ", request.method);
if(request.method == 'POST' ){
console.log("POST params should be next: ");
console.log(request.headers);
code = response.statusCode = 200;
response.write(code);
response.close();
}
});
when I run phantomjs on the command line, here is the output:
$ phantomjs.exe myscript.js
Start Application
Listen port 7788
null
request method: POST
POST params should be next:
[object Object]
POST params: 1=bill&2=dave
So it works. My question is how to parse the message body into variables, so I can access it in the rest of the script.
source
share