Creating Menu Services
Create the following file
services/Order.js
import API from './API.js';
export async function loadData() {
const data = await API.fetchMenu();
app.store.menu = data;
}
Now import the loadData
function in app.js
import { loadData } from "./services/Menu.js";
And finally replace the current DOMContentLoaded
event handler
window.addEventListener("DOMContentLoaded", () => {
loadData();
});
Create the function renderTest()
in app.js
for test that we can call from the console that will render a list of categories from the loaded data.