API POST
https://github.com/nicklasdean/post-error-handling
A) /new
Create a POST end-point that receives all data in a POST request of a new pokémon. The new pokémon will be inserted into the database with mysql2.
B) /updateHP
Create a POST endpoint that allows users to update the hp (health points) of an existing Pokémon by providing its id.
Steps
Create a
POSTendpoint at/updateHPthat accepts the Pokémonpokedex numberand the newhpvalue in the request body.Search the database for a Pokémon with the matching
pokedex number.If found, update the
hpvalue and return a success response. If not found, return a 404 error.Test the end-point with insomnia
C) /updateHP
Update the applications such that a user can update the HP of a pokemon with an HTML/CSS/JS front-end.
Steps
Add another form next to "Register new pokemon"submit theidand new HP with a fetch call.If found, update thehpvalue in the database of the pokemon.
D) Advanced (Optional)
Enhance the API such that the applications checks if the pokemon already exists.If a duplicate is found, respond with a 409 status code and an appropriate error message.
Last updated