Ok, so this is what I have:
const http = require("http");
const Server = function(){
this.context = {};
};
Server.prototype.callback = function(req, res){
console.log(this.context);
};
Server.prototype.listen = function(...arguments){
const server = http.createServer(this.callback);
return server.listen(...arguments);
};
module.exports = Server;
It logs context
as undefined
, but when I call the function without http.createServer
it works, why and how can I fix it?