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": "17"
},
{
"type": "navs",
"id": "14"
},
{
"type": "navs",
"id": "15"
},
{
"type": "navs",
"id": "16"
},
{
"type": "navs",
"id": "13"
},
{
"type": "navs",
"id": "7"
},
{
"type": "navs",
"id": "2"
},
{
"type": "navs",
"id": "10"
},
{
"type": "navs",
"id": "3"
}
]
}
},
"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"
},
{
"type": "navs",
"id": "15"
},
{
"type": "navs",
"id": "16"
},
{
"type": "navs",
"id": "17"
}
]
}
},
"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"
}
},
{
"type": "navs",
"id": "15",
"attributes": {
"parent_id": 11,
"lang": "en",
"path": "create-content-elements",
"name": "Create Content Elements",
"title": "Create PagibleAI Content Elements",
"to": "",
"domain": "",
"has": false,
"createdAt": "2025-08-17T06:36:28.000000Z",
"updatedAt": "2025-08-21T09:28:06.000000Z"
},
"links": {
"self": "https://pagible.com/cms/pages/15"
}
},
{
"type": "navs",
"id": "16",
"attributes": {
"parent_id": 11,
"lang": "en",
"path": "add-dynamic-content",
"name": "Add Dynamic Content",
"title": "Add dynamic Content to Pages",
"to": "",
"domain": "",
"has": false,
"createdAt": "2025-08-19T15:03:27.000000Z",
"updatedAt": "2025-08-21T09:28:06.000000Z"
},
"links": {
"self": "https://pagible.com/cms/pages/16"
}
},
{
"type": "navs",
"id": "17",
"attributes": {
"parent_id": 11,
"lang": "en",
"path": "install-pagibleai-cms",
"name": "Install PagibleAI",
"title": "Install PagibleAI CMS",
"to": "",
"domain": "",
"has": false,
"createdAt": "2025-08-20T22:44:16.000000Z",
"updatedAt": "2025-08-21T07:16:38.000000Z"
},
"links": {
"self": "https://pagible.com/cms/pages/17"
}
},
{
"type": "navs",
"id": "7",
"attributes": {
"parent_id": 1,
"lang": "en",
"path": "code",
"name": "Source Code",
"title": "PagibleAI CMS Source Code",
"to": "https://github.com/aimeos/pagible",
"domain": "",
"has": false,
"createdAt": "2025-08-05T08:16:37.000000Z",
"updatedAt": "2025-08-05T08:17:56.000000Z"
},
"relationships": {
"children": {
"data": []
}
},
"links": {
"self": "https://pagible.com/cms/pages/7"
}
},
{
"type": "navs",
"id": "2",
"attributes": {
"parent_id": 1,
"lang": "en",
"path": "blog",
"name": "Blog",
"title": "PagibleAI Blog",
"to": "",
"domain": "",
"has": true,
"createdAt": "2025-07-29T09:23:40.000000Z",
"updatedAt": "2025-08-20T09:00:42.000000Z"
},
"relationships": {
"children": {
"data": [
{
"type": "navs",
"id": "3"
},
{
"type": "navs",
"id": "10"
}
]
}
},
"links": {
"self": "https://pagible.com/cms/pages/2"
}
},
{
"type": "navs",
"id": "3",
"attributes": {
"parent_id": 2,
"lang": "en",
"path": "pagibleai-cms-powerful-simple-scalable-ai-content-management",
"name": "The Future of Content Management",
"title": "PagibleAI CMS: Powerful, Simple, Scalable AI Content Management",
"to": "",
"domain": "",
"has": false,
"createdAt": "2025-07-29T09:46:45.000000Z",
"updatedAt": "2025-08-20T09:00:42.000000Z"
},
"links": {
"self": "https://pagible.com/cms/pages/3"
}
},
{
"type": "navs",
"id": "10",
"attributes": {
"parent_id": 2,
"lang": "en",
"path": "ai-boosts-editor-productivity-the-pagibleai-revolution",
"name": "AI Content Creation",
"title": "AI Boosts Editor Productivity: The PagibleAI Revolution",
"to": "",
"domain": "",
"has": false,
"createdAt": "2025-08-06T14:50:50.000000Z",
"updatedAt": "2025-08-07T12:22:57.000000Z"
},
"links": {
"self": "https://pagible.com/cms/pages/10"
}
}
]
}