Improve error handling for menu data fetching and update HTML structure: Enhance error logging in menuDataController, provide user-friendly error messages, and streamline the index.html file by adding new script references while removing an unused image.
This commit is contained in:
@@ -1,24 +1,22 @@
|
||||
const { MenuItem } = require('../models');
|
||||
const { withDbRetries } = require('./withDbRetries');
|
||||
|
||||
async function fetchMenuData() {
|
||||
try {
|
||||
const menuItems = await MenuItem.findAll({
|
||||
order: [['order_id', 'ASC']],
|
||||
include: [{
|
||||
model: MenuItem,
|
||||
as: 'submenu',
|
||||
required: false,
|
||||
order: [['order_id', 'ASC']]
|
||||
}]
|
||||
});
|
||||
|
||||
const menuData = buildMenuStructure(menuItems);
|
||||
|
||||
return menuData;
|
||||
} catch (error) {
|
||||
console.error('There was a problem fetching the menu data:', error);
|
||||
return [];
|
||||
}
|
||||
return withDbRetries(
|
||||
async () => {
|
||||
const menuItems = await MenuItem.findAll({
|
||||
order: [['order_id', 'ASC']],
|
||||
include: [{
|
||||
model: MenuItem,
|
||||
as: 'submenu',
|
||||
required: false,
|
||||
order: [['order_id', 'ASC']]
|
||||
}]
|
||||
});
|
||||
return buildMenuStructure(menuItems);
|
||||
},
|
||||
{ attempts: 3, baseDelayMs: 200 }
|
||||
);
|
||||
}
|
||||
|
||||
function buildMenuStructure(menuItems) {
|
||||
|
||||
Reference in New Issue
Block a user