LuisPinto LuisPinto - 1 month ago 9
Node.js Question

Why am I getting req.isXHubValid is not a function

I'm configuring a route on express like this:

router.post('/my route', xhub({ algorithm: 'sha1', secret: APP_SECRET }), function (req, res, next) {
req.isXHubValid()


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

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 }));
app.use(bodyParser());
app.use(methodOverride());

UPDATE

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.

Comments