Clementine.js boilerplate question

Hello, I was looking through the clementine.js boilerplate and I have a weird question about it. After you log in the req param have the element user. My question is how it got there. I’ll be thankful if you could point me the part where it happends.

I don’t have time to dig through clementine, but I see no one has answered.

A “parameter” is encoded in the URL. So, if you have an API endpoint like http://mysite.com/user/bob123 I could have an API endpoint for /user/ and it gets bob123 as a parameter. In Node/Express, you might write it like:

app.get('/user/:username, function(req, res) {
  console.log('I got sent a username of', req.params.username)
})

So, anything in that slot will get put into that variable. You can have more than one.

app.get('/user/:username/:password, function(req, res) {
  console.log('I got sent a username of', req.params.username)
  console.log('I got sent a password of', req.params.password)
})

If you sent a url of ``http://mysite.com/user/bob123/bobrules`, the server could pull those out of the URL as params.

To answer your question directly, params are sent in the url string used in the AJAX call.

There are other ways to send information, namely body and query strings.

That information is stored in the server, usually in a session, and is shared back to the client in a cookie. Those are all things you can investigate.

Yes, this is all very confusing. Yes, it is difficult to understand until some of the pieces start to fall into place. Just keep at it.

It uses passport.js. You may find the “how” in passport docs, or use a tutorial online to learn about it.