- When a user submits the toy form, a
POST
request is sent tohttp://localhost:3000/toys
and the new toy is added to Andy's Toy Collection. - The toy should conditionally render to the page.
- In order to send a POST request via Fetch, give the Fetch a second argument of an object. This object should specify the method as
POST
and also provide the appropriate headers and the JSON-ified data for the request. If your request isn't working, make sure your header and keys match the documentation.
POST http://localhost:3000/toys
headers:
{
"Content-Type": "application/json",
Accept: "application/json"
}
body: JSON.stringify({
"name": "Jessie",
"image": "https://vignette.wikia.nocookie.net/p__/images/8/88/Jessie_Toy_Story_3.png/revision/latest?cb=20161023024601&path-prefix=protagonist",
"likes": 0
})
- For examples, refer to the documentation.
When a user clicks on a toy's like button, two things should happen:
- Conditional increase to the toy's like count without reloading the page
- A patch request sent to the server at
http://localhost:3000/toys/:id
updating the number of likes that the specific toy has - Headers and body are provided below (If your request isn't working, make sure your header and keys match the documentation.)
PATCH http://localhost:3000/toys/:id
headers:
{
"Content-Type": "application/json",
Accept: "application/json"
}
body: JSON.stringify({
"likes": <new number>
})