I have a table that returns JSON like this:
{
"status": 200,
"body": [
{
"category": "Sports",
"items": [
{
"id": 1,
"name": "Football"
},
{
"id": 1,
"name": "Volly"
},
{
"id": 2,
"name": "BasketBall"
}
]
},
{
"category": "Fruits",
"items": [
{
"id": 1,
"name": "Apple"
},
{
"id": 1,
"name": "Bananna"
},
{
"id": 2,
"name": "Orange"
}
]
},
{
"category": "Electronics",
"items": [
{
"id": 1,
"name": "Phone"
},
{
"id": 1,
"name": "Tablets"
},
{
"id": 2,
"name": "Computers"
}
]
}
],
}
The URL for this JSON will be like http://localhost:8080/categories
On my react native app I want to return all the items of each category based on the category name.
My question is which is the best approach to make this:
1: To communicate with this URL http://localhost:8080/categories and filter which category do I want on react native?
OR
2: To create two different URL for each category for example:
http://localhost:8080/fruits
SELECT ID, ITEM FROM CATEGORY WHERE CATEGORY.ID = 'fruits'
http://localhost:8080/sports
SELECT ID, ITEM FROM CATEGORY WHERE CATEGORY.ID = 'SPORTS'
The number 2 approach will return already a filtered response for me.