Just out of curiosity I started to play with Node.js, I create a simple server with this code:
var http = require("http");
http.createServer(function(request, response) {
......
}).listen(8888);
Inside the createServer function I have a simple string that I want to return to another app.
The workflow is:
- Other app send name and lastName
- Node.js app recieve this data
- Build the a JSON string with that data
- Retrieve the JSON string to the other app
Currently I'm hardcoding the name and lastName and building the JSON string with them, but I have all that code on the createServer function, but the problem is that the createServer function is called only on the server startup.
How can I receive and send data from a Node.js app to another app?
http://localhost:8888/app?name=foo&lastName=barand I want get the name and lastName from the request and create a JSON using that parameters and finally return the JSON