> For the complete documentation index, see [llms.txt](https://codedthemes.gitbook.io/berry/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://codedthemes.gitbook.io/berry/v3.9.0/routing/menu-from-the-backend.md).

# Menu from the backend

Berry is already loading few menus from backend for sample purpose. You can refer following area to check how its working:

1. &#x20;Open the file menu.ts *(src/store/slices/menu.ts)*, and check API URL in the getMenu function.

`const response = await axios.get(`**`'/api/menu/widget'`**`);`

2. Open the file App.tsx *(src/App.tsx),* and check the below code of the line.

<pre class="language-typescript"><code class="lang-typescript">import { useEffect, useState } from 'react';

import Loader from 'ui-component/Loader';

import { dispatch } from 'store';
import { getMenu } from 'store/slices/menu';

const App = () => {
    ...
<strong>    const [loading, setLoading] = useState&#x3C;boolean>(false);
</strong>
    useEffect(() => {
        dispatch(getMenu()).then(() => {
            setLoading(true);
        });
    }, []);

    if (!loading) return &#x3C;Loader />;
    ...
}

</code></pre>

3. Check code in *src/menu-items/*&#x77;idget.tsx. Icons and locale have been set according to API response in that.
4. Open the file *src/layout/MainLayout/MenuList/index.tsx*, and check the below code of the line.

```javascript
import { memo, useEffect } from 'react';

import { Menu } from 'menu-items/menu';

const MenuList = () => {
    ...
    useEffect(() => {
        handlerMenuItem();
        // eslint-disable-next-line
    }, []);

    let getMenu = Menu();
    const handlerMenuItem = () => {
        const isFound = menuItem.items.some((element) => {
            // use root parent id according to response instead of 'menu'
            if (element.id === 'menu') {
                return true;
            }
            return false;
        });

        if (getMenu?.id !== undefined && !isFound) {
            menuItem.items.splice(1, 0, getMenu);
        }
    };
    ...
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://codedthemes.gitbook.io/berry/v3.9.0/routing/menu-from-the-backend.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
