LuisPinto LuisPinto - 1 year ago 118
Node.js Question

Why am I getting req.isXHubValid is not a function

I'm configuring a route on express like this:'/my route', xhub({ algorithm: 'sha1', secret: APP_SECRET }), function (req, res, next) {

When I do this I'm getting

TypeError: req.isXHubValid is not a function

Ps: I'm requiring express-x-hub like
const xhub = require('express-x-hub')

Does anyone know how can I solve this? Thank you so much!

Answer Source

I hope that except for the require you are registering it as well. The example here:

var xhub = require('express-x-hub');
app.use(xhub({ algorithm: 'sha1', secret: XHUB_SECRET_HERE }));


If you read carefully the documentation:

Then add the middleware to Express.js. It needs to be one of the first and before bodyParser().

So, definitely registering at the context of your post route it will not work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download