首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当选项中给出方法时,nodejs requestify.request()崩溃

当选项中给出方法时,nodejs requestify.request()崩溃
EN

Stack Overflow用户
提问于 2017-04-09 18:56:49
回答 1查看 328关注 0票数 0

为什么requestify.request()崩溃,因为它认为它没有得到方法POST

代码语言:javascript
复制
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);
    });
});
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-09 18:57:47

看起来您使用的是新版本的requestify文档的旧版本。

阅读API reference部分的https://github.com/ranm8/requestify

然后再往下读,看到一个requestify.request()示例。

选项没有hostpath,.

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43310644

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档