By the end of today's lecture, you will be able to code a fetch
to add an object to a JSON file.
- Run
json-server --watch db.json
to start the JSON server. - Render each character to the screen within the
<li>
tag. - Add an event listener to create a new object upon submission of the form.
- Why must we use a submit event here? Why not another kind of event?
- Add the new object to the db.json file.
- What is a POST request?
- With our newfound information on
fetch
, why is it so necessary to both GET and POST requests?
- Render the new object to the screen.
- Does this new object persist? Why?
Monday's lecture will round out the four basic fetch
requests we will be learning by adding a PATCH request and a DELETE request.