-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
add: ctx.locals as a recommended namespace for passing information to the frontend #366
Conversation
alternatively, we could call it |
sweet! I agree with the name change to differentiate, ctx.state sounds fine to me! A little section in the docs would be awesome too if you have a minute |
done! let me know if there's anything else I should update. |
can we squash this? :) |
confusion of |
maybe if english is your second language :) it's not like you pronounce it |
When we add this we need to heavily stress the idiomatic use of this object to store auxiliary information. |
… through middleware and routes.
@jonathanong sure, not too familiar with that workflow. Should I open up a new PR with the single commit? |
@matthewmueller |
@dead-horse right, but i can't push this on the same branch because the commit histories don't match up. |
|
0e57678
to
6847fe6
Compare
ya'll are living on the edge, huh... pushed! |
add: ctx.locals as a recommended namespace for passing information to the frontend
thanks man! |
wow, I missed something. thanks @coderhaoxin |
use ctx.state, see koajs/koa#366
Just throwing this PR out there. It was discussed in: #338.
Basically this gives you a namespace to attach to that you don't have to worry about this object being undefined. Alternatively, you could always add:
at the top of your stack. I feel like this is common enough use-case that it should be added to core, but open to your thoughts.