Skip to content

Commit acfada5

Browse files
committed
Add new fields from database
1 parent 51ac466 commit acfada5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/api/Api.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ class Api {
2525
const finalArr = [];
2626
categories()
2727
.then((categoriesData) => {
28-
Object.keys(categoriesData).map((key, index) => {
28+
Object.keys(categoriesData).map((key) => {
2929
const title = key;
3030
const newTitle = title.charAt(0).toUpperCase() + title.slice(1);
31-
return finalArr.push({ id: index + 1, title: newTitle, thumbnail: undefined });
32-
// we have to add Thumbnail (both - to Firebase and a[[)
31+
return finalArr.push({ id: categoriesData[key], title: newTitle, thumbnail: undefined });
32+
// we have to add Thumbnail (both - to Firebase and app)
3333
});
3434
return finalArr;
3535
})
@@ -40,8 +40,9 @@ class Api {
4040
const itemsArray = []; // helper Array to store all formatted items
4141
Object.keys(siteData).map((key1, index1) => itemsArray.push({
4242
id: `${finalArr[index].id}_${index1}`,
43-
title: key1,
43+
title: siteData[key1].title,
4444
url: `http://${siteData[key1].url}`, // for now it will produce bad URL for links starting with http:// or https:// [needs to be changed in database]
45+
thumbnail: siteData[key1].thumbnail,
4546
}));
4647
newArray.push({ ...finalArr[index], items: itemsArray });
4748
if (newArray.length === finalArr.length) {

0 commit comments

Comments
 (0)