2017-04-09 69 views
0

为什么requestify.request()崩溃,因为它不认为这是给POST方法的NodeJS requestify.request()崩溃

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); 
    }); 
}); 

回答

0

它看起来像你使用旧版本的文件为requestify

新的版本阅读的https://github.com/ranm8/requestify

API reference部分和阅读只是有点低了下去就看到一个requestify.request()的例子。

选项没有hostpath,...