Loading src/main.ts +10 −3 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ async function main(): Promise<void> { objectName: 'node--recipe', }) ); console.log('--- Get collection from state if it already exists ---'); console.log( await store.getObject({ Loading Loading @@ -162,6 +163,12 @@ async function main(): Promise<void> { }) ); // It is possible to fetch menu data using the jsonapi_menu_items module along with jsonapi_hypermedia // jsonapi_hypermedia module: https://www.drupal.org/project/jsonapi_hypermedia // jsonapi_menu_items module: https://www.drupal.org/project/jsonapi_menu_items console.log('--- Fetch Menu items---'); console.log(await store.getObject({ objectName: 'menu_items--main' })); console.log(store.getState()); // Uncomment to use authenticated store - currently depends on local environment Loading web/src/config.ts +2 −1 Original line number Diff line number Diff line Loading @@ -44,8 +44,9 @@ export const SIDEBAR = { { text: 'GraphQL Queries (Experimental)', link: 'en/graphql-queries' }, { text: 'Authorization', link: 'en/authorization' }, { text: 'Additional Features', header: true }, { text: 'Common Use Cases', header: true }, { text: 'Getting Objects by Path', link: 'en/get-object-by-path' }, { text: 'Getting Menu Items', link: 'en/getting-menu-items' }, { text: 'Utilities', link: 'en/utilities' }, { text: 'Project Direction', header: true }, Loading web/src/pages/en/getting-menu-items.md 0 → 100644 +17 −0 Original line number Diff line number Diff line --- title: Getting Menu Items layout: ../../layouts/MainLayout.astro --- The `getObject` method can also be used to source menu data from Drupal if the `jsonapi_hypermedia` and `jsonapi_menu_items` modules are enabled. See https://www.drupal.org/project/jsonapi_hypermedia and https://www.drupal.org/project/jsonapi_menu_items for more details on enabling those modules in your Drupal instance. ```js const menuItems = await store.getObject({ objectName: 'menu_items--main', // Fetches the menu named `main` }); ``` Loading
src/main.ts +10 −3 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ async function main(): Promise<void> { objectName: 'node--recipe', }) ); console.log('--- Get collection from state if it already exists ---'); console.log( await store.getObject({ Loading Loading @@ -162,6 +163,12 @@ async function main(): Promise<void> { }) ); // It is possible to fetch menu data using the jsonapi_menu_items module along with jsonapi_hypermedia // jsonapi_hypermedia module: https://www.drupal.org/project/jsonapi_hypermedia // jsonapi_menu_items module: https://www.drupal.org/project/jsonapi_menu_items console.log('--- Fetch Menu items---'); console.log(await store.getObject({ objectName: 'menu_items--main' })); console.log(store.getState()); // Uncomment to use authenticated store - currently depends on local environment Loading
web/src/config.ts +2 −1 Original line number Diff line number Diff line Loading @@ -44,8 +44,9 @@ export const SIDEBAR = { { text: 'GraphQL Queries (Experimental)', link: 'en/graphql-queries' }, { text: 'Authorization', link: 'en/authorization' }, { text: 'Additional Features', header: true }, { text: 'Common Use Cases', header: true }, { text: 'Getting Objects by Path', link: 'en/get-object-by-path' }, { text: 'Getting Menu Items', link: 'en/getting-menu-items' }, { text: 'Utilities', link: 'en/utilities' }, { text: 'Project Direction', header: true }, Loading
web/src/pages/en/getting-menu-items.md 0 → 100644 +17 −0 Original line number Diff line number Diff line --- title: Getting Menu Items layout: ../../layouts/MainLayout.astro --- The `getObject` method can also be used to source menu data from Drupal if the `jsonapi_hypermedia` and `jsonapi_menu_items` modules are enabled. See https://www.drupal.org/project/jsonapi_hypermedia and https://www.drupal.org/project/jsonapi_menu_items for more details on enabling those modules in your Drupal instance. ```js const menuItems = await store.getObject({ objectName: 'menu_items--main', // Fetches the menu named `main` }); ```