nss-evening-cohort-11 / nutshell-ewoks-droids

Star Destroyer
0 stars 2 forks source link

Weapons Read Axios.get #18

Closed Nikababy01 closed 4 years ago

Nikababy01 commented 4 years ago

USER STORY

As a user, I should be able to view all Weapons.boards.

AC

WHEN the page loads I should see all boards THEN click a board by weapons type AND will view all weapons information

WIREFRAMES

image

image

DEV NOTES


  1. Create a axios.get function in weaponsData.js to get id const getWeaponsByid

    
    
    const getWeaponsbyId = (weaponsId) =>new Promise (resolve, reject) => {
          axios.get(`${baseUrl}/weapons.json? orderBy= "weaponsId"&equalTo="${weaponsId}"`)
             .then((response) => {
                const myWeapons= response.data;
                 const weapons = [];
                  Object.keys(myWeapons).forEach((weaponsId) => {
                    myWeapons[weaponsId].id = weaponsId;
                     weapons.push(myWeapons[weaponsId]);
                      });
                         resolve(weapons);
                      })
                        .catch(err) => reject(err));
                   });
    
    export default { getWeaponsbyId };

2. Create a domString to build the cards for the weaponsCard in a component ** weapons.js**
**const buildWeaponsCards**
```<ADD FUNCTION HERE>
const buildWeaponsCards =() => {
weaponsData.getWeaponsById(weaponsId)
.then ((weapons) => {
let domString = ' ';
domString  += 'h2 class= "text-center">Weapons</h2>;
domString += '<div class="d-flex flex-wrap">';
weapons.forEach((weapon)=>{
domString += weaponsComponent.weaponsMaker(weapon);
});
domString += '<div>';
utils.printToDom('weapons', domString);
3. Send this to the **printToDom** in **utils.js**

RELATED TICKETS

EX. #4