TypeError:无法读取未定义的属性'toString'

时间:2015-07-30 06:06:11

标签: javascript node.js request

我正在尝试将文件发送到服务器,但我收到的错误

错误:

poolKey += options.cert.toString('ascii') + options.key.toString('ascii'
                                                        ^
TypeError: Cannot read property 'toString' of undefined

我的nodejs代码:

var express = require('express');
var app = express();
var request = require('request');
var bodyParser = require("body-parser");
var fs = require('fs');
var https = require('https');

app.use(bodyParser.urlencoded({
  extended: false
}));

require('ssl-root-cas/latest').inject();

var options = {
  url: 'https://example.com',
  agentOptions: {
    cert: fs.readFileSync('tstr200011')
  },
  rejectUnauthorized: false
};

fs.createReadStream('data.xml')
  .pipe(request.post(options).auth('user', 'password', false));

0 个答案:

没有答案