This tutorial shows you how use the outfits_like
filter to return all clothing items that make up an outfit in the service.
This tutorial takes about 15 minutes to complete.
clothing
resources in the service have corresponding outfit
properties based on the outfits
resource. In other words, ensure that your outfits are represented in the outfits
property of your 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 outfits_like
filter to retrieve all clothing items with the same outfits
property.
The
{base_url}
for the service ishttp://localhost:3000
.
To find clothing resources that make up an outfit:
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
/clothing?outfits_like=cocktail party outfit
Content-Type: application/json
Watch for the response body, which should generate all clothing
resources that have cocktaill party outfit
listed in the outfits
property:
[
{
"name": "strappy heels",
"type": "footwear",
"color": "silver",
"description": "Looks amazing but not too comfortable",
"outfits": "wedding party outfit, cocktail party outfit",
"id": 6
},
{
"name": "little black dress",
"type": "dress",
"color": "black",
"description": "The name is self-explanatory",
"outfits": "cocktail party outfit",
"id": 13
},
{
"name": "pendant necklace",
"type": "accessory",
"color": "silver",
"description": "Gorgeous necklace from grandma -- don't lose!",
"outfits": "cocktail party outfit",
"id": 14
}
]
To add a clothing item to an existing outfit, refer to Add a new clothing item.
To return all outfit
resources that include a specific clothing item, refer to Get an outfit based on clothing items.