An alternative is to use a different configuration and this request:
https://pagible.com/cms/pages/1?include=menu,menu.children
To make this work, you need to change these settings in the ./config/cms.php file:
jsonapi_maxdepth
to 2
menu_maxdepth
to 1
Then, you will get a list in included too but the sub-items are referenced in the relationships field and the json-api-model JS library automatically create a tree structure from the response:
import { Store } from 'json-api-models';
const models = new Store();
models.sync(response);
const home = models.findAll().shift();
home?.menu?.forEach(child1 => {
child1.children.forEach(child2 => {
// ...
}
}
The response from the server to feed into the json-api-model library would be similar to:
{
"meta": {
"baseurl": "https://pagible.com/storage/"
},
"jsonapi": {
"version": "1.0"
},
"links": {
"self": "https://pagible.com/cms/pages/1"
},
"data": {
"type": "pages",
"id": "1",
"attributes": {
"parent_id": null,
"lang": "en",
"path": "",
"name": "Home",
"title": "Pagible AI CMS - Next level content management!",
"theme": "",
"type": "",
"to": "",
"domain": "",
"has": true,
"cache": 5,
"createdAt": "2025-07-29T09:00:58.000000Z",
"updatedAt": "2025-08-22T09:28:04.000000Z",
},
"relationships": {
"menu": {
"data": [
{
"type": "navs",
"id": "9"
},
{
"type": "navs",
"id": "11"
},
{
"type": "navs",
"id": "14"
},
{
"type": "navs",
"id": "13"
}
]
}
},
"links": {
"self": "https://pagible.com/cms/pages/1"
}
},
"included": [
{
"type": "navs",
"id": "9",
"attributes": {
"parent_id": 1,
"lang": "en",
"path": "demo",
"name": "Demo",
"title": "Demo",
"to": "https://pagible.demo.aimeos.org/cmsadmin",
"domain": "",
"has": false,
"createdAt": "2025-08-06T14:27:08.000000Z",
"updatedAt": "2025-08-06T14:28:32.000000Z"
},
"relationships": {
"children": {
"data": []
}
},
"links": {
"self": "https://pagible.com/cms/pages/9"
}
},
{
"type": "navs",
"id": "11",
"attributes": {
"parent_id": 1,
"lang": "en",
"path": "documentation",
"name": "Docs",
"title": "Documentation",
"to": "",
"domain": "",
"has": true,
"createdAt": "2025-08-16T20:46:38.000000Z",
"updatedAt": "2025-08-20T08:43:58.000000Z"
},
"relationships": {
"children": {
"data": [
{
"type": "navs",
"id": "13"
},
{
"type": "navs",
"id": "14"
}
]
}
},
"links": {
"self": "https://pagible.com/cms/pages/11"
}
}
{
"type": "navs",
"id": "13",
"attributes": {
"parent_id": 11,
"lang": "en",
"path": "json-rest-api",
"name": "JSON REST API",
"title": "PagibleAI JSON REST API",
"to": "",
"domain": "",
"has": true,
"createdAt": "2025-08-17T06:09:14.000000Z",
"updatedAt": "2025-08-21T12:54:20.000000Z"
},
"links": {
"self": "https://pagible.com/cms/pages/13"
}
},
{
"type": "navs",
"id": "14",
"attributes": {
"parent_id": 11,
"lang": "en",
"path": "customize-theme",
"name": "Customize Theme",
"title": "Customize PagibleAI Theme",
"to": "",
"domain": "",
"has": false,
"createdAt": "2025-08-17T06:35:16.000000Z",
"updatedAt": "2025-08-21T09:28:06.000000Z"
},
"links": {
"self": "https://pagible.com/cms/pages/14"
}
}
]
}