What is the meaning of "/:word"?

Why there is a “/:” before “word”, what’s the meaning of it ?

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36

Challenge: Get Route Parameter Input from the Client

Link to the challenge:

It’s a convention used when defining routes to indicate it gets replaced with a value.

So the example is

/user/:userId/book/:bookId

userId and bookId are values

You don’t go to a website & look up a users book literally like /user/:userId/book/:bookId, you go to a website & look up a users book like:

/user/546/book/6754

Then the framework can figure out the correct route (normally using regex, so you get /user, then an id, then /book, then an id), assign 546 as the user id and assign 6754 as the book id. Then you have those two values available to look up a database entry.

1 Like