title | description |
---|---|
Project Overview |
A first look at the project we'll build in this section. |
import VideoEmbed from "@site/src/components/VideoEmbed";
In this section we'll make a simple REST API that allows us to:
- Create stores, each with a
name
and a list of stockeditems
. - Create an item within a store, each with a
name
and aprice
. - Retrieve a list of all stores and their items.
- Given its
name
, retrieve an individual store and all its items. - Given a store
name
, retrieve only a list of item within it.
This is how the interaction will go!
:::tip Insomnia files Remember to get the Insomnia files for this section or for all sections here! :::
Request:
POST /store {"name": "My Store"}
Response:
{"name": "My Store", "items": []}
Request:
POST /store/My Store/item {"name": "Chair", "price": 175.50}
Response:
{"name": "Chair", "price": 175.50}
Request:
GET /store
Response:
{
"stores": [
{
"name": "My Store",
"items": [
{
"name": "Chair",
"price": 175.50
}
]
}
]
}
Request:
GET /store/My Store
Response:
{
"name": "My Store",
"items": [
{
"name": "Chair",
"price": 175.50
}
]
}
Request:
GET /store/My Store/item
Response:
[
{
"name": "Chair",
"price": 175.50
}
]