Closed christopherjohnson1 closed 4 years ago
WHEN the page loads and I am not logged in THEN I should see all the available personnel AND I should not be able add, edit, or delete them
personnelData.js
src/javascripts/helpers/data
axios
APIKeys
baseUrl
getPersonnel
new Promise
resolve
reject
axios.get()
.then()
.catch()
err
reject(err)
response
allPersonnel
response.data
personnel
(allPersonnel)
Object.keys
.forEach()
personnelId
.forEach
allPersonnel[personnelId].id = personnelId
.push()
resolve(personnel)
personnel.js
console.error
domString
<h2>
Personnel
<h3>
<h4>
utils.printToDom()
personnelCards
buildPersonnelCards
authData
buildAllPersonnel
checkLoginStatus
else
if...else
User Story
AC
WHEN the page loads and I am not logged in THEN I should see all the available personnel AND I should not be able add, edit, or delete them
Dev Notes
personnelData.js
file insrc/javascripts/helpers/data
axios
APIKeys
filebaseUrl
variable and give it a value of the database url in theAPIKeys
filegetPersonnel
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
allPersonnel
and give it a value ofresponse.data
personnel
(allPersonnel)
Object.keys
and pass inallPersonnel
as an argument.forEach()
to loop throughallPersonnel
personnelId
as the argument for the.forEach
allPersonnel[personnelId].id = personnelId
.push()
into thepersonnel
arrayresolve(personnel)
personnel.js
getPersonnel
.then()
and.catch()
.catch()
shouldconsole.error
a comment and the error.then()
should take the parameterpersonnel
domString
variable with an<h2>
element that saysPersonnel
and an<h3>
or<h4>
with a subtitle.forEach()
loop to go through the personnel array, and pass in personnel as an argument.forEach()
close any elements and then useutils.printToDom()
personnelCards
buildPersonnelCards
personnel
domString
variable and build a card using template literals to populate the name, description and imagepersonnelCards
topersonnel.js
.forEach()
looppersonnel.js
toauthData
buildAllPersonnel
incheckLoginStatus
in theelse
of theif...else