2016-10-07 4 views
1

Ich bin eine Route auf Eil wie diese Konfiguration:Warum erhalte ich req.isXHubValid ist keine Funktion

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

Wenn ich das tue ich

Typeerror bekommen: req.isXHubValid ist keine Funktion

Ps: ich express-x-Hub wie const xhub = require('express-x-hub')

Kennt jemand bin erfordern, wie ich dieses Problem lösen kann? Ich danke dir sehr!

+0

Übergeben Sie es als Middleware? –

Antwort

0

Ich hoffe, dass außer der erfordern Sie registrieren es auch. 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

Wenn Sie sorgfältig die Dokumentation zu lesen:

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

Also, auf jeden Fall im Rahmen Ihrer Post Route Registrierung wird es nicht funktionieren.

Verwandte Themen