Closed christopherjohnson1 closed 4 years ago
WHEN the page loads and I am not logged in THEN I should see all the planetary sectors AND I should not be able add, edit, or delete them
planetarySectorData.js
src/javascripts/helpers/data
axios
APIKeys
baseUrl
getPlanetarySectors
new Promise
resolve
reject
axios.get()
.then()
.catch()
err
reject(err)
response
allPlanetarySectors
response.data
planetarySectors
(allPlanetarySectors)
Object.keys
.forEach()
planetarySectorId
.forEach
allPlanetarySectors[planetarySector].id = planetarySectorId
.push()
resolve(planetarySectors)
planetarySectors.js
console.error
domString
<h2>
Planetary Sectors
<h3>
<h4>
utils.printToDom()
planetarySectorCards.js
buildPlanetarySectorCards
planetarySector
planetarySectorCards
authData
buildAllPlanetarySectors
checkLoginStatus
else
if...else
User Story
AC
WHEN the page loads and I am not logged in THEN I should see all the planetary sectors AND I should not be able add, edit, or delete them
Dev Notes
planetarySectorData.js
file insrc/javascripts/helpers/data
axios
APIKeys
filebaseUrl
variable and give it a value of the database url in theAPIKeys
filegetPlanetarySectors
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
allPlanetarySectors
and give it a value ofresponse.data
planetarySectors
(allPlanetarySectors)
Object.keys
and pass inallPlanetarySectors
as an argument.forEach()
to loop throughallPlanetarySectors
planetarySectorId
as the argument for the.forEach
allPlanetarySectors[planetarySector].id = planetarySectorId
.push()
into theplanetarySectors
arrayresolve(planetarySectors)
planetarySectors.js
getPlanetarySectors
.then()
and.catch()
.catch()
shouldconsole.error
a comment and the error.then()
should take the parameterplanetarySectors
domString
variable with an<h2>
element that saysPlanetary Sectors
and an<h3>
or<h4>
with a subtitle.forEach()
loop to go through the planetary sectors array, and pass inplanetarySectors
as an argument.forEach()
close any elements and then useutils.printToDom()
planetarySectorCards.js
buildPlanetarySectorCards
planetarySector
domString
variable and build a card using template literals to populate the name, description and imageplanetarySectorCards
toplanetarySectors.js
.forEach()
loopplanetarySectors.js
toauthData
buildAllPlanetarySectors
incheckLoginStatus
in theelse
of theif...else