KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm using Node.js to POST JSON to PostBin but the data is being wrongly formated (as you can see here: http://www.postbin.org/1cpndqw ). This is the code I'm using for tesT: var http = require('http'); var options = { host: 'www.postbin.org', port: 80, path: '/1cpndqw', method: 'POST' }; var req = http.request(options, function(res) { console.log('STATUS: ' + res.statusCode); console.log('HEADERS: ' + JSON.stringify(res.headers)); res.setEncoding('utf8'); res.on('data', function (chunk) { console.log('BODY: ' + chunk); }); }); req.write(JSON.stringify({ a:1, b:2, c:3 }, null, 4)); req.end();
Tags (comma-separated)
Save Edits
Cancel