From the course: Databases for Node.js Developers

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Add the basket to the page

Add the basket to the page

From the course: Databases for Node.js Developers

Start my 1-month free trial

Add the basket to the page

- [Instructor] As I said before, a basket is always for a given user, and if you remember in user management, we created this impersonate route before. So if I click on the email address of a user, we see that it somehow switches to user. Let's look again what we're doing here. So in Visual Studio Code now, in our user route when I scroll down, in the end I have this impersonate route and you see that we write the user ID into the session in line 92. If I look at the index route of our shop, so in routes, shop, index.js, we see that we there look for res.locals.currentUsers, so we look for the user object that is not just the ID but the whole user and it's stored in res.locals. Locals is a property on the response object which is available to all templates and if we look into our layout templates that can be found in server fuse, and you also see that I'm using the pack template engine here. When I scroll down, I see…

Contents