1
00:00:00,800 --> 00:00:05,390
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,390 --> 00:00:05,780
terminal.

3
00:00:06,320 --> 00:00:10,790
Now everything works pretty well, but this console log right here is kind of ugly and it's hard to

4
00:00:10,790 --> 00:00:12,670
understand in this kind of object format.

5
00:00:13,070 --> 00:00:19,070
So in this video, I want to pull off the ID title and completed flags and print them out in a nicer

6
00:00:19,070 --> 00:00:21,700
format, kind of like a little report of sorts.

7
00:00:22,580 --> 00:00:25,070
So let's try making some changes to our code base.

8
00:00:25,740 --> 00:00:29,840
I'm going to look back over to my editor and to get started, I'm going to first get a direct reference

9
00:00:29,840 --> 00:00:33,140
to the to do, which is that data property right there.

10
00:00:33,410 --> 00:00:37,640
So I'm going to essentially pull off that data property and assign it to a separate variable again,

11
00:00:37,640 --> 00:00:39,280
just to make it easier to work with.

12
00:00:40,020 --> 00:00:43,940
So I'll say const to do is response data.

13
00:00:44,810 --> 00:00:45,980
So now we've got that to do.

14
00:00:46,130 --> 00:00:52,940
We can pull off the ID, the title and completed properties, assign them to some temporary variables

15
00:00:53,300 --> 00:00:57,440
and then we can insert them all into a single string and console log that string to essentially put

16
00:00:57,440 --> 00:00:58,400
together our report.

17
00:01:00,490 --> 00:01:06,250
So I'm going to pull off those three properties we just took a look at, so I'll say const ID is to

18
00:01:06,250 --> 00:01:07,420
do dot ID.

19
00:01:08,510 --> 00:01:11,900
I'll get title as to do that title.

20
00:01:13,290 --> 00:01:14,730
And I'll say finished.

21
00:01:16,080 --> 00:01:19,230
Is to do dot finished like so.

22
00:01:20,240 --> 00:01:24,500
Now, if you're looking at these three lines of code and thinking, hey, Stephen, you just missed

23
00:01:24,500 --> 00:01:27,860
something up right here, that's totally fine, just bear with me for a second.

24
00:01:28,370 --> 00:01:31,910
If you're looking at this code and you don't see anything wrong, that's totally fine as well.

25
00:01:31,940 --> 00:01:33,710
Again, just bear with me for a moment.

26
00:01:34,610 --> 00:01:37,940
So now underneath that, we can start to print out a nice little report here.

27
00:01:38,360 --> 00:01:39,470
So I'll do a console log.

28
00:01:40,930 --> 00:01:46,600
To print out this as a nice little report, I want to use a multi-line string that is capable of using

29
00:01:46,600 --> 00:01:51,370
string templating, so I want to kind of inject some variables into the string to do so.

30
00:01:51,370 --> 00:01:55,870
We can use a template string, just as you might be familiar with from 2015.

31
00:01:56,650 --> 00:01:58,680
So inside, if you are going to put a set of tactics.

32
00:01:58,750 --> 00:02:00,000
Remember, these are tactics.

33
00:02:00,020 --> 00:02:02,350
It's the character to the left of the one on your keyboard.

34
00:02:02,500 --> 00:02:03,970
They are not single quotes.

35
00:02:05,040 --> 00:02:06,780
I'm going to turn this into a multiline string.

36
00:02:08,000 --> 00:02:12,140
And I'll say something like the to do with I.D..

37
00:02:13,870 --> 00:02:16,000
Colin and I'll print out the ID.

38
00:02:18,860 --> 00:02:23,240
Analogies like print out the title underneath, I'll say, as a title of.

39
00:02:24,440 --> 00:02:25,850
Dollar sign title.

40
00:02:27,660 --> 00:02:32,760
And I'll point out whether or not it is finished, so I'll say something like, is it finished?

41
00:02:34,100 --> 00:02:37,430
And I'll print in the finished variable like so.

42
00:02:39,090 --> 00:02:43,170
All right, so that's a little bit nicer to read report right there than the plane console log that

43
00:02:43,170 --> 00:02:43,830
we had before.

44
00:02:43,950 --> 00:02:46,740
So let's save this file and then attempt to run it at our terminal.

45
00:02:47,260 --> 00:02:53,190
So I'm going to flip back over to my terminal and I'll run the file in one step using T.S.A. once again.

46
00:02:53,190 --> 00:02:55,460
So I'll say T.S.A. index dot.

47
00:02:55,520 --> 00:02:55,910
Yes.

48
00:02:56,610 --> 00:02:58,860
Remember, we are feeding in the typescript file here.

49
00:02:58,890 --> 00:03:01,110
We're not making use of the plane JavaScript file anymore.

50
00:03:02,030 --> 00:03:02,990
So I'll run this command.

51
00:03:03,980 --> 00:03:10,220
And sure enough, I end up seeing undefined, undefined, undefined, what's up with that?

52
00:03:10,400 --> 00:03:11,360
That's kind of unexpected.

53
00:03:11,360 --> 00:03:15,100
We just saw all that didn't appear correctly a moment ago when we did the console log.

54
00:03:15,650 --> 00:03:18,120
So that means that we must have made a mistake somewhere in here.

55
00:03:18,620 --> 00:03:20,140
So what is going wrong?

56
00:03:21,130 --> 00:03:22,540
Well, let's take a quick pause right here.

57
00:03:22,540 --> 00:03:26,110
When we come back, the next video, we're going to make sure it's really clear what's wrong with this

58
00:03:26,110 --> 00:03:26,560
program.

59
00:03:26,560 --> 00:03:31,000
And we're going to start to discuss how we can easily use TypeScript to avoid making the error that

60
00:03:31,000 --> 00:03:32,520
we just made inside of here.

61
00:03:32,560 --> 00:03:34,620
So quick pause and I'll see you in just a minute.

