1

Is it possible to get the current request object in node.js express without passing it around?

I'm looking for something like I know from the spring framework.

Something like:

var req = express.getCurrentRequest(); 
3
  • did my answer explained what you were looking for ? Commented Dec 3, 2015 at 20:41
  • Somehow, I'll give you an upvote, but I'd like to wait till I accept an answer. Commented Dec 3, 2015 at 21:36
  • Would it be possible to use this framework? npmjs.com/package/continuation-local-storage Commented Dec 3, 2015 at 21:36

1 Answer 1

2

No it is possible to get the current request being served without passing it around. Your express server may be serving more than one request at any point of time and since Node.js is single threaded it is not possible to get hold of any specific request being served.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.