1 00:00:00,910 --> 00:00:05,410 In the last video we were able to write out some code to fetch a single to do and printed out at the 2 00:00:05,410 --> 00:00:06,400 terminal. 3 00:00:06,400 --> 00:00:11,320 Now everything works pretty well but this console log right here is kind of ugly and it's hard to understand 4 00:00:11,320 --> 00:00:13,120 in this kind of object format. 5 00:00:13,120 --> 00:00:19,030 So in this video I want to pull off the I.D. title and completed flags and print them out in a nicer 6 00:00:19,030 --> 00:00:19,720 format. 7 00:00:19,720 --> 00:00:22,500 Kind of like a little report of sorts. 8 00:00:22,630 --> 00:00:28,210 So let's try making some changes to our code base going to flip back over to my editor and to get started. 9 00:00:28,210 --> 00:00:33,470 I'm going to first get a direct reference to the to do which is that data property right there. 10 00:00:33,470 --> 00:00:37,240 So I'm going to essentially pull off that data property and assign it to a separate variable. 11 00:00:37,330 --> 00:00:39,840 Again just to make it easier to work with. 12 00:00:40,090 --> 00:00:44,880 So I'll say cons to do is response dot data. 13 00:00:44,950 --> 00:00:51,550 Now we've got that to do we can pull off the I.D. the title and completed properties I'll assign them 14 00:00:51,550 --> 00:00:56,260 to some temporary variables and then we can insert them all into a single string and console log that 15 00:00:56,260 --> 00:01:02,050 string to essentially put together our report so I'm gonna pull off those three properties. 16 00:01:02,050 --> 00:01:11,900 We just took a look at it's all say concept I.D. is to do dot I.D. I'll get title as to do dot title 17 00:01:13,410 --> 00:01:18,740 and I'll say finished is to do dot finished. 18 00:01:18,740 --> 00:01:24,760 Like so now if you're looking at these three lines of code and thinking hey steven you just missed something 19 00:01:24,760 --> 00:01:25,540 up right here. 20 00:01:25,690 --> 00:01:26,500 That's totally fine. 21 00:01:26,500 --> 00:01:28,230 Just bear with me for a second. 22 00:01:28,450 --> 00:01:31,960 If you're looking at this code and you don't see anything wrong that's totally fine as well. 23 00:01:31,960 --> 00:01:34,630 Again just bear with me for a moment. 24 00:01:34,650 --> 00:01:38,320 So now underneath that we can start to print out a nice little report here. 25 00:01:38,440 --> 00:01:42,950 So I'll do a console log to print out this as a nice little report. 26 00:01:42,960 --> 00:01:47,400 I want to use a multi line string that is capable of using string templating. 27 00:01:47,400 --> 00:01:53,370 So I want to kind of inject some variables into the string to do so we can use a template string just 28 00:01:53,370 --> 00:01:56,700 as you might be familiar with from yes 2015. 29 00:01:56,700 --> 00:02:00,060 So inside if you're going to put a set of back ticks remember these are back ticks. 30 00:02:00,060 --> 00:02:02,520 It's the character to the left or the one on your keyboard. 31 00:02:02,550 --> 00:02:05,010 They are not single quotes. 32 00:02:05,150 --> 00:02:14,350 I'm going to turn this into a multi line string and I'll say something like the to do with Ida a colon 33 00:02:14,470 --> 00:02:15,970 and I'll print out the idea 34 00:02:18,960 --> 00:02:25,430 and I'll just like print out the title underneath I'll say as a title of dollar sign. 35 00:02:25,430 --> 00:02:29,730 Title and I'll print out whether or not it is finished. 36 00:02:29,780 --> 00:02:39,110 So I'll say something like Is it finished and I'll print in the finished variable like so. 37 00:02:39,220 --> 00:02:43,240 All right so that's a little bit nicer to read report right there than the plain console log that we 38 00:02:43,240 --> 00:02:44,010 had before. 39 00:02:44,020 --> 00:02:47,280 So let's save this file and then attempt to run it at our terminal. 40 00:02:47,300 --> 00:02:53,170 It's going to flip back over my terminal and I'll run the file in one step using T.S. node once again 41 00:02:53,330 --> 00:02:56,400 I'll say T.S. node index dot T.S.. 42 00:02:56,680 --> 00:02:58,900 Remember we are feeding in the typescript file here. 43 00:02:58,900 --> 00:03:05,170 We're not making use of the plain JavaScript file anymore so I'll run this command and sure enough I 44 00:03:05,170 --> 00:03:08,780 end up seeing undefined undefined undefined. 45 00:03:08,940 --> 00:03:10,410 Oh what's up with that. 46 00:03:10,420 --> 00:03:11,350 That's kind of unexpected. 47 00:03:11,350 --> 00:03:15,700 We just saw all that data appear correctly a moment ago when we did the console log. 48 00:03:15,700 --> 00:03:18,640 So that means that we must have made a mistake somewhere in here. 49 00:03:18,670 --> 00:03:21,170 So what is going wrong. 50 00:03:21,210 --> 00:03:22,520 Well let's take a quick pause right here. 51 00:03:22,530 --> 00:03:26,590 When we come back the next video we're going to make sure it's really clear what's wrong with this program. 52 00:03:26,610 --> 00:03:30,990 And we're going to start to discuss how we can easily use typescript to avoid making the error that 53 00:03:30,990 --> 00:03:32,530 we just made inside of here. 54 00:03:32,640 --> 00:03:34,960 So quick pause and I'll see you in just a minute.