0 1 00:00:00,450 --> 00:00:02,120 All right so here comes the answer. 1 2 00:00:03,090 --> 00:00:08,880 Before you do anything I recommend reading through the docs and seeing how these parameters work. 2 3 00:00:08,940 --> 00:00:15,390 And remember that we're using the colon and then we're going to give our parameter a name so that we 3 4 00:00:15,390 --> 00:00:21,540 can tap into it later on using req.params. the name that we specified. 4 5 00:00:21,750 --> 00:00:27,030 So now we can head into our app.js and you can create that route any way you wish. 5 6 00:00:27,300 --> 00:00:29,930 I'm going to put it just before the end right down here 6 7 00:00:29,940 --> 00:00:36,510 just before my app.listen. And I'm going to say app.get and then I'm going to specify / 7 8 00:00:36,660 --> 00:00:44,250 posts/: and then here comes the name of my parameter which you can call anything you 8 9 00:00:44,250 --> 00:00:45,930 wish as long as it makes sense to you 9 10 00:00:46,080 --> 00:00:55,200 but I'll call it postName. And then I'll add my callback, my req and res and then inside my callback I 10 11 00:00:55,200 --> 00:00:59,070 am going to tap into that parameter called postName. 11 12 00:00:59,070 --> 00:01:09,360 So I want to console log it. So I'm going to log the req.params.postName. And it has 12 13 00:01:09,360 --> 00:01:13,450 to be spelt exactly the same as you see here after the colon. 13 14 00:01:13,590 --> 00:01:15,410 But there's no colons down here 14 15 00:01:15,420 --> 00:01:21,700 remember that. This is all that you need in order to tap into a dynamic 15 16 00:01:21,720 --> 00:01:22,890 URL right? 16 17 00:01:22,920 --> 00:01:28,890 Because we're using this parameter to decide what it is that we should do inside our app.get. 17 18 00:01:28,920 --> 00:01:36,360 So we can now say if they said I wanted you know the post that has a post name of testing then we will 18 19 00:01:36,540 --> 00:01:37,770 send them over there 19 20 00:01:37,830 --> 00:01:43,940 and if they wanted the post that had a name of ordinary I love pets then we will show them that page. 20 21 00:01:43,950 --> 00:01:48,450 So this is the first step towards getting a dynamic website created. 21 22 00:01:48,600 --> 00:01:53,570 And this is all down to using Node and Express, nothing else. 22 23 00:01:53,590 --> 00:02:01,060 Now we can test this and if we head over to posts/ anything you want to write afterwards then 23 24 00:02:01,060 --> 00:02:05,320 it will get logged down here in our console. 24 25 00:02:05,350 --> 00:02:11,080 So this is the first step towards achieving our dynamic website and feel free to mess around with it, 25 26 00:02:11,210 --> 00:02:17,080 try out different parameter names, try out multiple parameters as you can see where they've got 26 27 00:02:17,440 --> 00:02:21,420 this one which is a single parameter and this one which is another parameter 27 28 00:02:21,610 --> 00:02:26,780 and you can actually tap into both just by using req.params. the name of your parameter in your 28 29 00:02:26,780 --> 00:02:27,590 URL. 29 30 00:02:27,790 --> 00:02:31,450 So play around with that and once you're ready we'll head over to the next challenge.