Open
Description
Since version 0.8 http.createClient is depreciated (no longer works) and produces an error. Rewrite for http.request is required.
This is what I have written instead. Do with as you please as it comes without warranty.
(function() {
var Blitline, http,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
http = require('http');
module.exports = Blitline = (function() {
function Blitline() {
this.postJobs = __bind(this.postJobs, this);
this.addJob = __bind(this.addJob, this);
}
Blitline.jobs = [];
Blitline.prototype.addJob = function(jobHash) {
this.jobs = this.jobs || [];
return this.jobs.push(jobHash);
};
Blitline.prototype.postJobs = function(callback) {
var body, options, req,
_this = this;
body = JSON.stringify({
"json": this.jobs
});
options = {
"host": "api.blitline.com",
"port": 80,
"path": "/job",
"method": "post",
"headers": {
'Content-Length': body.length,
'Content-Type': 'application/json'
}
};
req = http.request(options, function(res) {
var result;
result = [];
res.on("data", function(chunk) {
return result.push(chunk.toString());
});
res.resume();
return res.on("end", function() {
return callback(null, result.join());
});
});
req.on("error", function(e) {
console.log("ERROR:Blitline:ErrorHandler: ", e);
return callback(e, null);
});
req.write(null, body);
return req.end();
};
return Blitline;
})();
}).call(this);
works for me but i dont know if it is inline with your intent/its not well tested. Some modification/cleanup may be required. It returns the raw response not json(which could be changed with ease).
Written with node 0.8.20.
Regards
Adam
Metadata
Metadata
Assignees
Labels
No labels