Skip to content

TypeError: Cannot set property 'useErrorHandler' of undefined #50

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
elliotlings opened this issue Jun 24, 2017 · 3 comments
Closed

TypeError: Cannot set property 'useErrorHandler' of undefined #50

elliotlings opened this issue Jun 24, 2017 · 3 comments

Comments

@elliotlings
Copy link

Any ideas why I am getting this error?

Running Node v6.10.2

/Users/elliotlings/api/node_modules/express-oauth-server/index.js:25
  this.useErrorHandler = options.useErrorHandler ? true : false;
                       ^

TypeError: Cannot set property 'useErrorHandler' of undefined
    at ExpressOAuthServer (/Users/elliotlings/api/node_modules/express-oauth-server/index.js:25:24)
    at Object.<anonymous> (/Users/elliotlings/api/src/index.js:9:13)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:393:7)
    at startup (bootstrap_node.js:150:9)
    at bootstrap_node.js:508:3
@elliotlings
Copy link
Author

Sorry, this was me being dumb.

I put

app.oauth = OAuthServer(...)

instead of

app.oauth = new OAuthServer(...)

:)

@TheModFather
Copy link

Just to close the gap how this could happen:

https://github.com/oauthjs/express-oauth-server/tree/master/examples/mongodb

shows the following example:
app.oauth = oauthserver({ debug: true, model: require('./model') });

That's likely where @elliotlings found the example.
If I can find the time, I'll submit a pull request with the fix unless someone else does first.

@brenc
Copy link

brenc commented Jul 28, 2018

I just hit this issue myself. The Postgres example is also wrong.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants