-
-
Save chapel/835322 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'); | |
var querystring = require('querystring'); | |
var data = { | |
message: 'Hello' | |
}; | |
var form_data = querystring.stringify(data); | |
var options = { | |
host: 'localhost', | |
port: 8088, | |
path: '/test', | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/x-www-form-urlencoded', | |
'Content-Length': form_data.length | |
} | |
}; | |
var req = http.request(options); | |
req.write(form_data); | |
req.end(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express.createServer(); | |
app.use(express.bodyDecoder()); | |
app.post('/test', function(req, res){ | |
console.log(req.body.message); | |
}); | |
app.listen(8088); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment