1 00:00:00,820 --> 00:00:06,490 We can see different question now by specifying an ID in the URL. 2 00:00:06,490 --> 00:00:09,640 But how can we view answers to those questions? 3 00:00:11,050 --> 00:00:16,860 We could add a another URL parameter after the ID that would look for a string. 4 00:00:16,860 --> 00:00:19,520 For example question or answer. 5 00:00:19,520 --> 00:00:20,040 This would work. 6 00:00:20,040 --> 00:00:24,090 But there's another way to pass information to a server I want to show 7 00:00:24,090 --> 00:00:26,050 you, it's called a query string. 8 00:00:27,150 --> 00:00:33,500 A query string goes at the end of a URL and it starts with a question mark. 9 00:00:33,500 --> 00:00:34,640 After the question mark, 10 00:00:34,640 --> 00:00:39,420 you can pass the server a key value pair separated by an equal sign. 11 00:00:41,140 --> 00:00:45,930 You can separate additional key value pairs with an ampersand like you see here. 12 00:00:46,970 --> 00:00:50,950 Let's use a query string to request either the answer or 13 00:00:50,950 --> 00:00:53,790 the question side of the flash card. 14 00:00:53,790 --> 00:00:58,700 We could use the side key to either be question or answer. 15 00:00:59,960 --> 00:01:03,390 Checking for a query string is very similar to checking for 16 00:01:03,390 --> 00:01:05,760 a route parameter or a cookie. 17 00:01:05,760 --> 00:01:09,043 If a query string is in the request, 18 00:01:09,043 --> 00:01:14,411 it will be in the request object under the query property. 19 00:01:14,411 --> 00:01:19,990 In the cards routes file, let's check for the presence of a query string key site. 20 00:01:30,334 --> 00:01:36,069 I'm assigning it to the variable side since question and 21 00:01:36,069 --> 00:01:39,660 answer are properties on the json. 22 00:01:43,950 --> 00:01:50,540 We can use the value stored inside to find the text we want to display. 23 00:01:50,540 --> 00:01:54,060 First though, we need the ID of the card. 24 00:01:57,880 --> 00:02:02,270 Let's create a variable to hold the ID from the route parameter. 25 00:02:06,044 --> 00:02:11,250 Now we can access the two pieces of text that we want to use. 26 00:02:11,250 --> 00:02:14,910 Let's store that in a constant named text. 27 00:02:22,713 --> 00:02:25,410 Also I'll store a reference to the hint. 28 00:02:35,544 --> 00:02:37,678 Now I'll wrap the text and 29 00:02:37,678 --> 00:02:42,340 the hint into an object that I can pass into the template. 30 00:02:57,358 --> 00:03:00,574 Lastly, I need to change the variable name for 31 00:03:00,574 --> 00:03:03,470 in the card template from prompt to text. 32 00:03:06,860 --> 00:03:11,260 This ensures the question or the answer will show up. 33 00:03:14,045 --> 00:03:18,550 Let's go back to the browser and try using our query string. 34 00:03:22,022 --> 00:03:23,420 The question shows up. 35 00:03:28,690 --> 00:03:30,680 And the answer shows up too. 36 00:03:31,770 --> 00:03:34,590 The only thing that I'd like to change is for 37 00:03:34,590 --> 00:03:40,720 the hint to show up only when the question side is showing, and not the answer side. 38 00:03:40,720 --> 00:03:44,910 See if you can use your understanding of Express and Java Script in general 39 00:03:44,910 --> 00:03:49,130 to only show the hint on the question side of the flash card. 40 00:03:49,130 --> 00:03:51,790 In the next video I'll show you my solution.