Define dynamic routes through Express

Share this video with your friends

Send Tweet

Routing is a fundamental aspect of Express. This lesson demonstrates how to define dynamic routes and access route parameters in your code.

Benjamin
Benjamin
~ 7 years ago

maybe its just that im a newb did i miss something where i was supposed to fork and clone a repo for this lesson? i am coding along with the guy so all of a sudden he has a user.json file in the second lesson. i went to github and just copied it to where im doing the lesson but that wasn't entirely obvious. i make this comment only because this is a beginner level course. But like i said maybe i missed instructions somewhere.

Wellyngton Amaral
Wellyngton Amaral
~ 7 years ago

No Benjamin. The problem is that he doesn't doing a step by step course. What he does is to copy and paste code he thinks is no important. I think its a pretty bad approach for a beginners tutorial.

2359 Media
2359 Media
~ 7 years ago

I agree this is not a good practice for beginners, though maybe that isn't the target audience. But there is a lot of assumptions in those first 15 seconds. Anyway, to support anyone trying to keep up:

  1. Create users.json file in root directory
  2. Copy, paste, save content from here
  3. In command line run npm install --save file-system lodash
  4. In index.js, call utilities with: var fs = require('file-system') (or ('fs') as per video) and var _ = require('lodash')
  5. Copy and paste the file system function from here
Tahsin Yazkan
Tahsin Yazkan
~ 6 years ago

How is it possible to have "user.name.full" value. We are not creating this variable there, because there isn't any var keyword before the name, first and last are the properties of name object, but where does full property come ?

Zac Dobbs
Zac Dobbs
~ 5 years ago

@Tahsin he's pulling it from the users.JSON file

Slawek
Slawek
~ 5 years ago

@Tahsin, yes we do in readFile line #12