Shortcut method similar to http.get() for HTTP POST requests with support for data and files


This utility extends the funcationlity of the 'http' library in stock node.js. It returns a post request function in a very similar way to node's http.get().

In the same style as http.get(), this function calls req.end() automatically

npm install http-post
http-post(options, data[, files[, callback]])


http-post(options, data[, callback])

Options are the same as the ones for http.request() except method will always be forced to POST. Note that options can be replaced with the full URI of the request similar to http.get allowing for even greater flexiblity in your post requests.

Data should be key/value pairs of form data. This does not handle file data, see the files option below for more information on uploading files.

var data = {
    name: "Sam",
    email: "",
    gender: "m",
    languages: [

Pass it an empty array if you do not need to send any form data.


Callback is the same from http.request(). It accepts an instance of http.ClientResponce that has been created during the time of the request.

Returns an instance of http.ClientRequest

Setting up

var http = require('http'); = require('http-post');

Posting data'http://localhost/postscript.php', { name: 'Sam', email: '' }, function(res){
    res.on('data', function(chunk) {

The MIT License