Closed github-learning-lab[bot] closed 3 years ago
With this last push, your repository should look like this.
💡 You can use dynamic variables to search for specific data associated with an id in your database, and return that (instead of just returning the id).
In Express, words with a colon in front of them in the url are treated as variables. You can access the value of each variable through req.params, like this:
Let's test it out!
Add the function above your
app.listen
function in your server.js file, restart the server, and paste this into your browser url: http://localhost:8000/users/markNow check the terminal for the console.log of req.params.id. You should see the name 'mark', since it is the value we passed in place of the 'id' variable. Since we are running this in the terminal, our console.log will appear there (instead of the browser).
After testing that it works, push your changes your GitHub repo: