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

Support for promise #277

Open
thethakuri opened this issue Jan 22, 2023 · 2 comments
Open

Support for promise #277

thethakuri opened this issue Jan 22, 2023 · 2 comments

Comments

@thethakuri
Copy link

thethakuri commented Jan 22, 2023

I am writing a custom token with async callback method that looks up value in a database. Problem is http request is logged in as [object Promise] for the custom token and doesn't "await" for the value to be resolved. Is there a workaround for this?

@dougwilson
Copy link
Contributor

Hi @thethakuri right now all format functions and token functions are expected to be sync. We can add async support, however.

@qq1147050160
Copy link

qq1147050160 commented Dec 1, 2023

Maybe you can do this:

morgan(
  (tokens, req, res) => {
    oneAsyncFunction(tokens, req, res)
    return null
  },
  { ... }
)

you can replace stream function.

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

3 participants