Created
July 15, 2014 21:05
-
-
Save victorkurauchi/6bc1e84aa11867f71c85 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 querystring = require('querystring') | |
| , http = require('http'); | |
| var data = querystring.stringify({ | |
| username: 'yourUsernameValue', | |
| }); | |
| var options = { | |
| host: 'http://localhost', | |
| port: 3000, | |
| path: '/api/product', | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/x-www-form-urlencoded', | |
| 'Content-Length': Buffer.byteLength(data) | |
| } | |
| }; | |
| var req = http.request(options, function(res) { | |
| res.setEncoding('utf8'); | |
| res.on('data', function (chunk) { | |
| console.log("body: " + chunk); | |
| }); | |
| }); | |
| console.log(req); | |
| req.write(data); | |
| req.end(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment