Sunday, 9 April 2017

nodejs requestify.request() crashes when the method is given in the options

Why does requestify.request() crash because it doesn't think it was given the method 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);
    });
});



via Steve

No comments:

Post a Comment