WEBVTT 0 00:00.450 --> 00:02.120 All right so here comes the answer. 1 00:03.090 --> 00:08.880 Before you do anything I recommend reading through the docs and seeing how these parameters work. 2 00:08.940 --> 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 00:15.390 --> 00:21.540 can tap into it later on using req.params. the name that we specified. 4 00:21.750 --> 00:27.030 So now we can head into our app.js and you can create that route any way you wish. 5 00:27.300 --> 00:29.930 I'm going to put it just before the end right down here 6 00:29.940 --> 00:36.510 just before my app.listen. And I'm going to say app.get and then I'm going to specify / 7 00:36.660 --> 00:44.250 posts/: and then here comes the name of my parameter which you can call anything you 8 00:44.250 --> 00:45.930 wish as long as it makes sense to you 9 00:46.080 --> 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 00:55.200 --> 00:59.070 am going to tap into that parameter called postName. 11 00:59.070 --> 01:09.360 So I want to console log it. So I'm going to log the req.params.postName. And it has 12 01:09.360 --> 01:13.450 to be spelt exactly the same as you see here after the colon. 13 01:13.590 --> 01:15.410 But there's no colons down here 14 01:15.420 --> 01:21.700 remember that. This is all that you need in order to tap into a dynamic 15 01:21.720 --> 01:22.890 URL right? 16 01:22.920 --> 01:28.890 Because we're using this parameter to decide what it is that we should do inside our app.get. 17 01:28.920 --> 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 01:36.540 --> 01:37.770 send them over there 19 01:37.830 --> 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 01:43.950 --> 01:48.450 So this is the first step towards getting a dynamic website created. 21 01:48.600 --> 01:53.570 And this is all down to using Node and Express, nothing else. 22 01:53.590 --> 02:01.060 Now we can test this and if we head over to posts/ anything you want to write afterwards then 23 02:01.060 --> 02:05.320 it will get logged down here in our console. 24 02:05.350 --> 02:11.080 So this is the first step towards achieving our dynamic website and feel free to mess around with it, 25 02:11.210 --> 02:17.080 try out different parameter names, try out multiple parameters as you can see where they've got 26 02:17.440 --> 02:21.420 this one which is a single parameter and this one which is another parameter 27 02:21.610 --> 02:26.780 and you can actually tap into both just by using req.params. the name of your parameter in your 28 02:26.780 --> 02:27.590 URL. 29 02:27.790 --> 02:31.450 So play around with that and once you're ready we'll head over to the next challenge.