Closed christopherjohnson1 closed 4 years ago
as a user I should be able to edit an enemy
WHEN the user logs in THEN there should be an edit button on all enemy cards AND you should be able to update any enemy item with a modal form
<div>
id="edit-enemy-modal"
id="add-new-enemy-modal"
buildEnemyCards
class="edit-enemy-btn"
editEnemyForm
enemiesData
utils
id="submit-enemy-edit"
editEnemyItem
enemies.js
enemiesData.js
updateEnemy
axios.put(enemyId, editedEnemyItem)
editedEnemyItem
key:value
.then()
buildAllEnemies
.catch()
User Story
as a user I should be able to edit an enemy
AC
WHEN the user logs in THEN there should be an edit button on all enemy cards AND you should be able to update any enemy item with a modal form
Dev Notes
<div>
withid="edit-enemy-modal"
at the top of index.html, underid="add-new-enemy-modal"
and above everything elsebuildEnemyCards
functionclass="edit-enemy-btn"
editEnemyForm
functioneditEnemyForm
editEnemyForm
functionenemiesData
utils
id="submit-enemy-edit"
editEnemyItem
which lives inenemies.js
enemiesData.js
make a new function calledupdateEnemy
that usesaxios.put(enemyId, editedEnemyItem)
methodeditedEnemyItem
that has thekey:value
pairs the same as the original seed data objectsupdateEnemy
ineditEnemyItem
.then()
callsbuildAllEnemies
.catch()
should console.error a comment and the error