1
00:00:00,300 --> 00:00:02,890
All right, I think we're solid on filter functionality.

2
00:00:03,390 --> 00:00:09,180
So now let's spice things up and implement the dynamic approach, since it's highly unlikely that we'll

3
00:00:09,180 --> 00:00:13,210
send our responses based on hard coded filter values.

4
00:00:13,830 --> 00:00:19,110
And first, let's start with our requests, more specifically query prompts, because that's how we

5
00:00:19,110 --> 00:00:20,120
will get our data.

6
00:00:20,700 --> 00:00:24,140
And in order to jog your memory on query string primes.

7
00:00:24,480 --> 00:00:27,930
Let's go back to my favorite API place for this course.

8
00:00:28,200 --> 00:00:32,780
I've called the APIs Hacker News by Ogola API.

9
00:00:33,240 --> 00:00:39,270
And once we navigate here, once we start scrolling and everything and looks like I'll have to refresh,

10
00:00:39,600 --> 00:00:44,220
you can see that of course we can get the items, we can provide the root problems.

11
00:00:44,440 --> 00:00:45,180
That's clear.

12
00:00:45,480 --> 00:00:52,410
But if we keep on scrolling notice, of course, now we can start searching for some data.

13
00:00:52,740 --> 00:00:54,220
And how do they set up the search?

14
00:00:54,510 --> 00:00:56,130
Well, I have the domain.

15
00:00:56,530 --> 00:01:00,450
Then, of course, they have some kind of end point that ends with search.

16
00:01:00,810 --> 00:01:02,090
And then I have a question mark.

17
00:01:02,610 --> 00:01:08,250
And after the question mark, we have crawler repairs, which essentially are query string parameters.

18
00:01:08,460 --> 00:01:14,130
And then, of course, based on what you're looking for, whether you want to set the query or you want

19
00:01:14,130 --> 00:01:20,300
to look for different page, then you pass in the value and hopefully you get the correct result.

20
00:01:20,550 --> 00:01:26,250
And as far as our setup, we first need to understand how we can send those query string parameters

21
00:01:26,430 --> 00:01:27,630
from the postman.

22
00:01:27,780 --> 00:01:28,210
Correct.

23
00:01:28,620 --> 00:01:33,410
So let me open up the postman and then, of course, I'm going to be looking for get all products,

24
00:01:33,780 --> 00:01:36,570
so I'll just leave the testing one as it is.

25
00:01:37,000 --> 00:01:42,270
So essentially in there we'll just hardcourt all the time but back and get our products.

26
00:01:42,600 --> 00:01:47,460
Not only I'm going to be looking for the product, but I can go with Questionmark and then of course

27
00:01:47,460 --> 00:01:48,990
I can add key value.

28
00:01:49,560 --> 00:01:50,700
Now we have two options.

29
00:01:51,030 --> 00:01:57,660
Either you can type it here, for example, or you could say name is equal to John and notice how right

30
00:01:57,660 --> 00:02:00,450
away they're being added in this table as well.

31
00:02:00,780 --> 00:02:06,090
So that's the second option where if you don't want to do it in the URL, you can just set it up over

32
00:02:06,090 --> 00:02:06,360
here.

33
00:02:06,390 --> 00:02:10,410
And what's really cool, you can actually check and uncheck them.

34
00:02:10,650 --> 00:02:17,700
And what that means is that if I go here with John and then of course I send again the name and if I

35
00:02:17,700 --> 00:02:19,650
don't want to send, then I can just remove it.

36
00:02:19,980 --> 00:02:24,990
And if I want to take a look at the featured ones and of course, this is going to be featured.

37
00:02:26,150 --> 00:02:32,450
And as far as featured, I want to start with Drew, and then once we send course now, we'll just get

38
00:02:32,450 --> 00:02:33,230
back the message.

39
00:02:33,470 --> 00:02:40,610
But if we take a look at our controller, we should have access to those key value pairs in that query.

40
00:02:40,880 --> 00:02:41,890
So let's start out.

41
00:02:42,190 --> 00:02:47,730
I'm going to go with simple console log just so we can see that we are getting data and it is sitting

42
00:02:47,750 --> 00:02:52,730
in Iraq and query and let's do it one more time from the postman.

43
00:02:52,740 --> 00:02:54,140
So let's send it again.

44
00:02:54,440 --> 00:02:56,480
We get back the hard hardcoded result.

45
00:02:56,750 --> 00:02:58,700
But take a look at our console.

46
00:02:59,090 --> 00:03:00,980
Of course, I didn't see that I have the object.

47
00:03:01,370 --> 00:03:07,460
And then and then I have developers with whatever I'm setting up in the postman.

48
00:03:07,820 --> 00:03:11,240
And once we have jog their memory on queries from parameters.

49
00:03:11,420 --> 00:03:18,110
Now, I simply want to go back to the postman and I'll just use the featured and I'll show you in a

50
00:03:18,110 --> 00:03:19,430
second why I want to do that.

51
00:03:19,640 --> 00:03:21,320
And then I'll send it, of course.

52
00:03:21,500 --> 00:03:25,350
And if I take a look at my app, of course, now I only have feature.

53
00:03:25,820 --> 00:03:33,380
So now let's set up the logic where our remove control log and then we'll still be looking for the product

54
00:03:33,800 --> 00:03:35,510
and we'll use the fine, of course.

55
00:03:35,780 --> 00:03:42,830
But in this case, instead of hard coding, instead of setting up the object and then passing in whatever

56
00:03:42,830 --> 00:03:46,710
key and then the value, of course, will pass in directly.

57
00:03:46,880 --> 00:03:53,000
Gregory, now we will refactor the code because there are some gotchas we need to be aware of, but

58
00:03:53,240 --> 00:03:58,130
with the most basic setup will pass the query directly into the find.

59
00:03:58,520 --> 00:04:01,170
And let's hope that we'll get some results.

60
00:04:01,490 --> 00:04:08,840
So let's start the same way we'll go with const products and that is equal to a weight and then product.

61
00:04:09,700 --> 00:04:17,769
Then fine, then, like I said, well, directly passing wreck and clearing, and of course, once I

62
00:04:17,769 --> 00:04:21,459
get back the results, I want to also send them on line.

63
00:04:21,459 --> 00:04:26,800
In this case, I'm going to remove the message and I'll just say the same thing where all passing the

64
00:04:26,800 --> 00:04:29,570
product as well as the length of my ring.

65
00:04:29,620 --> 00:04:33,160
So that way I know how much I'm sending so I can go back.

66
00:04:33,160 --> 00:04:40,360
And then one more time from the postman and again the route is forward slash product, not testing one.

67
00:04:41,220 --> 00:04:46,830
And now we're just passing featured because that is one of the keys that I have and as far as the value

68
00:04:47,010 --> 00:04:54,360
I go through, and then once we send check it out now, of course, we have the product and the amount

69
00:04:54,360 --> 00:04:56,530
of items is equal to seven.

70
00:04:56,730 --> 00:05:01,640
So if I change this to false now, of course, I'll get a different set of values.

71
00:05:01,940 --> 00:05:08,580
Again, let's just quickly cover the logic where we have access to query string parameters in Iraq that

72
00:05:08,610 --> 00:05:09,090
query.

73
00:05:09,480 --> 00:05:14,300
And since we get back the object, we can directly pass it into the final one.

74
00:05:14,790 --> 00:05:20,820
And since in this case I'm looking for featured and I'm setting it equal to true.

75
00:05:21,090 --> 00:05:24,060
That, of course, returns only the products that are featured.

76
00:05:24,300 --> 00:05:31,410
And then if we pass in the false and of course we'll get only the product where feature is set to false.

