I have added a response class in expressjs as follows
module.exports = function(req,res) {
this.req = req;
this.res = res;
console.log(this.res);
this.ok = function() {
this.res.status(200).end();
}
this.err = function(err) {
console.log(this.res);
this.res.status(400).json({err:err.message});
}
};
And i am calling it using
route.post("/",function(req,res){
var authCtx = new authHelper(req,res);
var respCtx = new response(req,res);
authCtx.checkForm()
.then(respCtx.ok)
.catch(respCtx.err);
});
The problem is when i create an object of class the first console.log
prints the complete response fine without any errors but in second case when error is invoked the this.res
becomes empty. Where am i going wrong with this ?
via georoot
No comments:
Post a Comment