1
00:00:09,210 --> 00:00:10,200
In this video.

2
00:00:10,200 --> 00:00:13,980
Let's see how we can solve the course error.

3
00:00:14,070 --> 00:00:18,380
So now we are shifting from the client side to our server.

4
00:00:18,390 --> 00:00:21,240
So now back to our Node.js server.

5
00:00:21,540 --> 00:00:27,210
Let's go to the terminal and we are going to install a package called Cost.

6
00:00:27,240 --> 00:00:28,440
So let's clear it.

7
00:00:28,440 --> 00:00:34,290
And now and P and I and then the name of the package that is cost.

8
00:00:35,070 --> 00:00:36,150
Now it's done.

9
00:00:36,150 --> 00:00:39,690
Let's clear now and let's restart our server.

10
00:00:40,200 --> 00:00:43,530
So here that is inside the server file.

11
00:00:48,070 --> 00:00:51,820
So next is you are going to pass course as a middleware.

12
00:00:51,820 --> 00:00:55,650
So make sure that you are the course before your route.

13
00:00:55,660 --> 00:01:04,420
So here you're going to be course middleware, you make use of app dot use, and then you pass in the

14
00:01:04,420 --> 00:01:06,060
course as a function.

15
00:01:06,070 --> 00:01:07,510
Now we are done.

16
00:01:07,690 --> 00:01:13,350
So let's get back to our client side and now let's try to log login again.

17
00:01:13,360 --> 00:01:15,460
Let me clear the console here.

18
00:01:15,560 --> 00:01:17,920
Now let me try again here st.

19
00:01:18,070 --> 00:01:19,360
Now let's wait.

20
00:01:19,540 --> 00:01:26,170
This time around we got the same access error, but lucky for us we have what is called the response.

21
00:01:26,380 --> 00:01:31,750
Remember I pass in some wrong password here, so let's open the response.

22
00:01:31,750 --> 00:01:35,740
And now on the response we have what is called data.

23
00:01:35,740 --> 00:01:43,960
And this is a message from our back end with invalid login credentials and then start us called Field

24
00:01:44,140 --> 00:01:47,310
and it's coming from our API.

25
00:01:47,320 --> 00:01:53,500
If you go to the controllers and then the users and log in, which is this.

26
00:01:53,500 --> 00:02:00,560
Remember we pass in the error as invalid login credentials and that is what we are receiving.

27
00:02:00,610 --> 00:02:05,190
So now let's go ahead and log in with the right credentials.

28
00:02:05,200 --> 00:02:12,400
So let me pass in the one, two, three, four, five and let me clear the console before I send.

29
00:02:12,550 --> 00:02:18,520
Now you see, now you got something back which is beautiful than before.

30
00:02:18,520 --> 00:02:26,730
So if I open it and now I'm a data, you can see we have the user a great.

31
00:02:26,740 --> 00:02:34,210
So what we want is that we are going to save the entire user here into local storage.

32
00:02:34,210 --> 00:02:42,340
So the same thing from the back end, if I go to the API and I click send, this is what you saw inside

33
00:02:42,340 --> 00:02:43,390
the client side.

34
00:02:43,390 --> 00:02:46,150
So now everything works fine.

35
00:02:46,150 --> 00:02:51,370
Then this video, let's finish up with the reducer and then the action.

