Closed christopherjohnson1 closed 4 years ago
WHEN the page loads and I am not logged in THEN I should see all the available enemies AND I should not be able add, edit, or delete them
enemiesData.js
src/javascripts/helpers/data
axios
APIKeys
baseUrl
getEnemies
new Promise
resolve
reject
axios.get()
.then()
.catch()
err
reject(err)
response
allEnemies
response.data
enemies
(allEnemies)
Object.keys
.forEach()
enemyId
.forEach
allEnemies[enemyId].id = enemyId
.push()
resolve(enemies)
enemies.js
console.error
domString
<h2>
Enemies
<h3>
<h4>
utils.printToDom()
enemyCards
buildEnemyCards
authData
buildAllEnemies
checkLoginStatus
else
if...else
User Story
AC
WHEN the page loads and I am not logged in THEN I should see all the available enemies AND I should not be able add, edit, or delete them
Dev Notes
enemiesData.js
file insrc/javascripts/helpers/data
axios
APIKeys
filebaseUrl
variable and give it a value of the database url in theAPIKeys
filegetEnemies
that makes anew Promise
(takes two parameter ofresolve
andreject
) and callsaxios.get()
.then()
and.catch()
.catch()
takes a single parameter oferr
and then does this:reject(err)
.then()
takes a parameter ofresponse
allEnemies
and give it a value ofresponse.data
enemies
(allEnemies)
Object.keys
and pass inallEnemies
as an argument.forEach()
to loop throughallEnemies
enemyId
as the argument for the.forEach
allEnemies[enemyId].id = enemyId
.push()
into theenemies
arrayresolve(enemies)
enemies.js
getEnemies
.then()
and.catch()
.catch()
shouldconsole.error
a comment and the error.then()
should take the parameterenemies
domString
variable with an<h2>
element that saysEnemies
and an<h3>
or<h4>
with a subtitle.forEach()
loop to go through the enemies array, and pass in enemies as an argument.forEach()
close any elements and then useutils.printToDom()
enemyCards
buildEnemyCards
enemies
domString
variable and build a card using template literals to populate the name, description and imageenemyCards
toenemies.js
.forEach()
loopenemies.js
toauthData
buildAllEnemies
incheckLoginStatus
in theelse
of theif...else