Closed christopherjohnson1 closed 4 years ago
WHEN the page loads and I am not logged in THEN I should see all the available weapons AND I should not be able add, edit, or delete them
weaponsData.js
src/javascripts/helpers/data
axios
APIKeys
baseUrl
getWeapons
new Promise
resolve
reject
axios.get()
.then()
.catch()
err
reject(err)
response
allWeapons
response.data
weapons
(allWeapons)
Object.keys
.forEach()
weaponId
.forEach
allWeapons[weaponId].id = weaponId
.push()
resolve(weapons)
weapons.js
console.error
domString
<h2>
Weapons
<h3>
<h4>
utils.printToDom()
weaponCards
buildWeaponCards
authData
buildAllWeapons
checkLoginStatus
else
if...else
User Story
AC
WHEN the page loads and I am not logged in THEN I should see all the available weapons AND I should not be able add, edit, or delete them
Dev Notes
weaponsData.js
file insrc/javascripts/helpers/data
axios
APIKeys
filebaseUrl
variable and give it a value of the database url in theAPIKeys
filegetWeapons
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
allWeapons
and give it a value ofresponse.data
weapons
(allWeapons)
Object.keys
and pass inallWeapons
as an argument.forEach()
to loop throughallWeapons
weaponId
as the argument for the.forEach
allWeapons[weaponId].id = weaponId
.push()
into theweapons
arrayresolve(weapons)
weapons.js
getWeapons
.then()
and.catch()
.catch()
shouldconsole.error
a comment and the error.then()
should take the parameterweapons
domString
variable with an<h2>
element that saysWeapons
and an<h3>
or<h4>
with a subtitle.forEach()
loop to go through the weapons array, and pass in weapons as an argument.forEach()
close any elements and then useutils.printToDom()
weaponCards
buildWeaponCards
weapons
domString
variable and build a card using template literals to populate the name, description and imageweaponCards
toweapons.js
.forEach()
loopweapons.js
toauthData
buildAllWeapons
incheckLoginStatus
in theelse
of theif...else