Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

TypeError: morgan.token is not a function #3

Closed
mehtatejas opened this issue Oct 3, 2018 · 4 comments
Closed

TypeError: morgan.token is not a function #3

mehtatejas opened this issue Oct 3, 2018 · 4 comments

Comments

@mehtatejas
Copy link

I am trying to add token to morgan logs.
However, I am getting following error :
morgan.token("conversation-id", function getConversationId(req) {
^

TypeError: morgan.token is not a function

Kindly guide

@nemanjapetrovic
Copy link
Owner

@mehtatejas

Sorry for late response, I have a hard time working on open source lately, I am trying...

I fixed this issue with v1.0.6 version of mongoose-morgan. Please try by updating version of your package.json mongoose-morgan dependency.

How will this work:

const mongooseMorgan = require('mongoose-morgan');

mongooseMorgan.token("conversation-id", function getConversationId(req) {
....
...
});

app.use(mongooseMorgan({
    connectionString: 'mongodb://localhost:27017/MongooseMorganUnit'
}, {}, 'short'));

....

@georgerussellpruitt
Copy link

I am experiencing this problem in version 1.0.8

@nemanjapetrovic
Copy link
Owner

nemanjapetrovic commented Jan 31, 2019

@georgerussellpruitt

I just tested this with v1.0.8 and I couldn't reproduce the problem, can you post here the code sample which reproduced the problem for you?

@p6297
Copy link

p6297 commented Mar 26, 2023

app.use(morgan(':method :url :status :res[content-length] - :response-time ms'))

just use this as the middleware.

please let me know if this is helpful to you

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

No branches or pull requests

4 participants