有些家伙正试图帮助我使用Node.js脚本。
见下文:
module.exports = function(context, cb) {
var https = require('https');
var body = JSON.stringify(context.data);
var options = {
hostname: 'seguroviagem.srv.br',
port: 443,
path: '/seguro-viagem/selecionar.json',
method: 'POST',
headers: {
"Authorization": "Token",
"Content-Type": "application/x-www-form-urlencoded"
"Content-Length": Buffer.byteLength(body)
}
};
var req = https.request(options, function(res) {
var dadosRetorno = '';
res.on('data', function(d) {
dadosRetorno += d.toString('utf8');
});
res.on('end', function(){
cb(null, { message : dadosRetorno });
});
});
req.end();
req.on('error', (e) => {
cb(null, { message : e });
});
};
API正在给出这个答案:
{
"code": 400,
"message": "Compilation failed: Unexpected string",
"error": "Unexpected string",
"stack": "SyntaxError: Unexpected string\n
at Object.exports.runInThisContext (vm.js:53:16)\n
at WebtaskModule.compileWebtask (/data/sandbox/lib/module.js:95:32)\n
at defaultJavascriptCompiler (/data/sandbox/lib/compiler.js:127:30)\n
at defaultCompiler (/data/sandbox/lib/compiler.js:136:16)\n
at /data/sandbox/lib/compiler.js:233:17\n
at /data/sandbox/node_modules/async/lib/async.js:718:13\n
at Immediate.iterate [as _onImmediate] (/data/sandbox/node_modules/async/lib/async.js:262:13)\n
at processImmediate [as _immediateCallback] (timers.js:383:17)"
}
缺少什么?