Implementing POST Servers

Implementing a POST server is similar to implementing a GET server. In fact, you may end up implementing them together in the same code for the sake of convenience. POST servers are handy if you need to send data to the server to be updated, as with form submissions. To serve a POST request, you need to implement code in the request handler that reads the contents of the post body out and processes the contents.

Once you have processed the data, you dynamically populate the data you want to send back to the client, write it out to the response, and then call end() to finalize the response and flush the Writable stream. Just as with a dynamic GET server, the output of a POST request may be a webpage, an HTTP snippet, ...

Get Node.js, MongoDB, and AngularJS Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.