I am exploring the idea of creating a dynamic sidebar with links fetched from an API. The theme I am currently working with can be found here:
One interesting feature in this theme is the charts link, which displays a list of children in the sidebar.
My goal is to utilize an API request, let's say for charts, and dynamically generate each child element (check out charts.js) for every item returned by the API.
In the code snippet below, you'll notice that the data objects are currently hardcoded. My intention is to eliminate this hardcoding and use a for loop to dynamically create each child based on the elements received in the API request body.
/store/modules/menu/index.js
[Code block for /store/modules/menu/index.js]
/store/modules/menu/charts.js
[Code block for /store/modules/menu/charts.js]
sidebar.vue
[Code block for sidebar.vue]
I seem to be stuck on this implementation. Any tips or guidance would be greatly appreciated.
Update:
Below is an example of the API response I am dealing with:
[
{
"id": 1,
"name": "test1",
"os": "windows",
"url": "https://test.com"
},
{
"id": 2,
"name": "test2",
"os": "ios",
"url": "https://test.com"
},
{
"id": 1,
"name": "test3",
"os": "windows",
"url": "https://test.com"
}
]