truonghm truonghm - 7 months ago 56
Node.js Question

Difference response for difference request in NodeJS

I'm a newbie in NodeJS and ExpressJS framework. I'm not sure about this thing: If the system receive many requests then server return many difference responses for those users, right? So they're not affect each other, right?

Example:I set language for request of user 1 in response.locals.language = 'english' then for user 2 is response.locals.language = 'vietnamese' on 2 separate browsers. If I refresh user 1 page so is language of user 2 change from vietnamese to english?

Thanks for your help.

rsp rsp

Every request gets its own request and response object, that is separate from other requests.

See the documentation, specifically:

Those object are passed as arguments to your handler. It's like a normal function that gets fresh arguments on every invocation.