Sunday, 9 April 2017

nodejs requestify.request crashes "I need to know the method" when the method is given in the options

Why does requestify.request() crash saying

" Cannot execute HTTP request without specifying method"

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



via user2367083

No comments:

Post a Comment