Hello!
I'm using Metronic Vue version 8.1.8.
To manage permissions on the server side, I would like to create the main menu asynchronously by making a request to the server using the ApiService.
I made the following changes in the original Metronic Vue Demo7 component /src/layouts/main-layout/aside/Menu.vue:
Commented out the line that imports MainMenuConfig.
// import MainMenuConfig from "@/core/config/MainMenuConfig";
const MainMenuConfig = ref<Array<any>>([]);
onMounted(async () => {
if (scrollElRef.value) {
scrollElRef.value.scrollTop = 0;
}
ApiService.setHeader();
await ApiService.get("/api/menu")
.then(({ data }) => {
MainMenuConfig.value = data
})
});
Hi Fernando,
Please make sure your request passes successfully and data is received.
If you are following the same object structure as in the default Metronic theme then your code should be working.
Could you please check your browser's console for errors?
Regards,
Lauris Stepanovs,
Keenthemes Support Team
Hi Lauris,
Sorry, I found a difference in the result coming from the server.
It worked. Thank you.
Hi Fernando,
Glad to hear that. Please don't hesitate to reach out if you need anything more from us.
Regards,
Lauris Stepanovs,
Keenthemes Support Team