Welcome back.
So now that we have set up our specific content, piece or card should look like for our categories.
Let's go ahead and actually.
Set it up so that it loads data and displays it right here.
Therefore, let's create a method that gives us the.
Items by category, because here so far, we have gotten them by country, right?
But now we're going to search them by category.
We could, of course, say we also want to get the country, but yeah, let's just go ahead and do it
like, so all right.
So we're going to use a new function, get articles by category
excel or by categories, whatever should be fine.
And here I'm going to use the query keyword.
I'm going to pass in the category.
So and then I'm going to get to category which will be of type string.
The second part of the query will be at query, which will be the API key.
So it's going to be.
This will be the same thing as we have done here.
So the only thing that we're changing is basically going to be the key word, the query, key words
that we're passing.
So we're now passing that country, but category.
So now let's set up our news manager, that's the news manager can work with it because we had this
news response before we had the selected category, but now we also need to get the category by while
the article by category so private vol.
Basically the same thing that we did here and let me just set it up real quick underscore get article
by category, which will still be a mutable state of top news response.
And then this will be get article by category, which will be a mutable state so we can change.
That state will not just be a normal state, which would be immutable.
We can change it off top news response and it will be a.
Remember, Composable gets her of the get article by category, so this is just worth creating a satire
and get her right so we can get the data from other classes, but we can only set them inside of the
news manager itself.
And now we can go ahead and create a method that will process this, so we had this get articles and
now we're going to get articles by category, which will be very similar to what we built there.
So fun.
Get articles by category.
And we need to pass in the category and then we need to prepare our client with the API key.
And then and cue.
Actually, we need to do the same thing.
So let me just.
Put it in here like so so we need to get the API key, we get not top articles, but this time we get
articles by category and we need to pass in the category here.
So it's not going to be us always, which is not even a category, but we need to pass in the category
name itself.
So here we're passing the category and then we're passing the API key.
So we need to use the service we NQ.
We want to use a callback with top news response when we get the response.
If it was successful, we're going to set our get article by category value to be the response body
and we're going to display this as category like.
So and if we get an error, we're going to display the response code or message either way is fine.
Thanks so.
And on failure, which is going to disprove a failure, so you see, it's pretty similar, but pretty
much the same.
Thing the only difference is that we're now passing the category in and not.
The.
Country anymore.
And obviously, we're changing.
A different variable.
So we changed this variable that we have used here.
And now we can actually use it in our newspaper and to be more precise in our.
Bottom navigation one, we're working with the categories, so here we can now pass the news manager
as we've done.
And we can call our news manager thought, get articles by category where we pass it to it.
So when we're fetching the category, it will get the selected category and then it will get the articles
by that category.
And then finally.
When we load the page itself, so when we get to the categories route or categories page, we also need
to get the articles by category like sole because I don't want the screen to be empty before we selected
anything, and I'm just going to set the default to be business.
And let's do the same thing with on selected category changed by default to be also business.
Thanks so.
OK.
So let me see business like this, not double e, but double this.
All right.
This category does exist in our categories.
And now if you run it and we check it out, we will see that we do get well.
If we search for category, we do get content.
So here we'll get our news, our international news.
So Peter product, it's a look.
So by Vienna 80, they have posted something and so forth.
So we do get the data.
Now we just need to display it.
It should be.
Should be instead of the cart where we have the roll with the modifier.
Well, actually, this article countered Wait a second, so it should be in the categories page itself.
So here we have our lazy roll.
And under this lazy roll, that's where I want to display the article content.
So I'm going to use my news manager.
Don't get article by category, not value thought.
Article.
More articles, which will be a list of so if it's empty and just going to pass an empty list of things,
so.
OK, so now let's check it up again.
And let's go over to the categories.
And there we are.
So now we see the business category content that we see the entertainment content.
The general content and so forth.
All right.
So now we don't only load it, but we are also displaying it, so this part here is quite important.
Well, we are actually using now our article content composable.
All right.
So that's it for this video.
See you in the next one.