🐛 Check items exist before itterating #415

This commit is contained in:
Alicia Sykes 2022-01-17 19:52:15 +00:00
parent b76b8eb620
commit f25aa07d5f
1 changed files with 4 additions and 2 deletions

View File

@ -70,8 +70,10 @@ const store = new Vuex.Store({
getItemById: (state, getters) => (id) => {
let item;
getters.sections.forEach(sec => {
const foundItem = sec.items.find((itm) => itm.id === id);
if (foundItem) item = foundItem;
if (sec.items) {
const foundItem = sec.items.find((itm) => itm.id === id);
if (foundItem) item = foundItem;
}
});
return item;
},