This tutorial shows you how to use the clothingItems_like
filter to return outfits in the service that use a specific clothing item.
This tutorial takes about 15 minutes to complete.
clothingItems
property that corresponds to items from the clothing
resource.NOTE: Ensure that the json-server version that you installed is 0.17.4 or older, or the
like
filter does not render results.
Use the GET
method and the clothingItems_like
filter to retrieve all outfits with the same clothingItems
property.
The
{base_url}
for the service ishttp://localhost:3000
.
To find outfits based on the clothingItems propery:
If your local service is not running yet, start it with the following command:
cd <your-github-workspace>/coordinista-service/api
json-server -w coordinista-db.json
GET
/outfits?clothingItems_like=backpack
Content-Type: application/json
backpacks
in the clothingItems
property:[
{
"name": "mountain hiking outfit",
"season": "winter",
"event": "outdoors",
"description": "Hiking? In the winter? Extremely unlikely but not impossible.",
"clothingItems": "long-sleeved shirt, waterproof pants, hiking boots, beanie, backpack",
"id": 1
},
{
"name": "picnic outfit",
"season": "spring",
"event": "outdoors",
"description": "Cottage-core, but make it practical.",
"clothingItems": "long-sleeved shirt, denim jeans, sneakers, backpack",
"id": 4
}
]
To add an outfit to the service, refer to Post a new outfit.
To add a clothing item to an existing outfit, refer to Add a new clothing item.