Initializing Router Service
Create a new service
/services/Router.js
const Router = {
init: () => {
},
go: (route, addToHistory=true) => {
}
}
export default Router;
And let's import this new service from app.js
and call it from DOMContentLoaded
import Router from './services/Router.js';
window.addEventListener("DOMContentLoaded", () => {
app.router.init();
loadData();
});