nodejs requestify.request() 在选项中给出方法时崩溃
nodejs requestify.request() crashes when the method is given in the options
为什么 requestify.request() 会崩溃,因为它认为没有给它方法 POST
var postBody = querystring.stringify(dat);
var postOptions = {
host: 'https://www.example.com'
, path: '/admin'
, method: 'post' // POST, 'POST', post
, headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postBody) }
};
var postReq = requestify.request(postOptions, function (err, resp, respBody) {
resp.setEncoding('utf8');
resp.on('data', function (chunk) {
console.log('Response: ' + chunk);
});
});
看起来您正在为新版本的 requestify 使用旧版本的文档
阅读 https://github.com/ranm8/requestify
的 API reference
部分
再往下读一点,它会看到一个 requestify.request() 示例。
选项没有 host
、path
、...
为什么 requestify.request() 会崩溃,因为它认为没有给它方法 POST
var postBody = querystring.stringify(dat);
var postOptions = {
host: 'https://www.example.com'
, path: '/admin'
, method: 'post' // POST, 'POST', post
, headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postBody) }
};
var postReq = requestify.request(postOptions, function (err, resp, respBody) {
resp.setEncoding('utf8');
resp.on('data', function (chunk) {
console.log('Response: ' + chunk);
});
});
看起来您正在为新版本的 requestify 使用旧版本的文档
阅读 https://github.com/ranm8/requestify
的API reference
部分
再往下读一点,它会看到一个 requestify.request() 示例。
选项没有 host
、path
、...