Node中的API请求返回错误

我使用一些请求参数向Sphere Engine API发出一个简单的http请求。 但是,我不能解释这个错误。 API规范: http : //sphere-engine.com/services/docs/compilers#status

码:

http = require('http') ; var info = { sourceCode: 'print 3+4', language: 4, input: '' } ; var infoString = JSON.stringify(info); var options = { host: 'api.compilers.sphere-engine.com', port: 80, path: '/api/v3/submissions?access_token=b11bf50b8a391d4e8560e97fd9d63460', method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': infoString.length } } ; var req = http.request(options,function(res) { res.setEncoding('utf-8'); var responseString = '' ; res.on('data', function(data) { responseString += data ; }); res.on('end', function() { var resultObject = JSON.parse(responseString); }); } ); req.write(infoString); req.end(); 

错误:

 undefined:0 ^ SyntaxError: Unexpected end of input at Object.parse (native) at IncomingMessage.<anonymous> (/Users/sarthakmunshi/nodetry.js:29:27) at IncomingMessage.emit (events.js:117:20) at _stream_readable.js:943:16 at process._tickCallback (node.js:419:13) 

       

网上收集的解决方案 "Node中的API请求返回错误"