question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

apostrophe-pages data object returns an empty array under the "_children" key, even after configuration

See original GitHub issue

Currently running version ^2.91.0 of Apostrophe in my project running on Node 12.1.0. I’m using Apostrophe as my headless backend, feeding data to my separate front end application. I am trying to access the children of apostrophe-pages to appear in my data object, however the _children array always returns as an empty array. My pages have 4 levels of child pages and they are all set up in the front end. I specifically need to access the time stamp of “CreatedAt” and “UpdatedAt” of all the children which is why fetching data from “api/v1/apostrophe-pages?all=true&hideOrphans=true” does not suffice as it only returns limited information. Fetching every child via their _id does not seem like the most viable option when fetching volumes deep. If there is a way to access all the children from their top parent level, that would be the most optimal in this case.

My index.js for the lib/modules/apostrophe-pages module contains the following: addFields: [ { name: '_pages', type: 'joinByArray', withType: 'apostrophe-page', label: 'Pages', idsField: 'pageIds', filters: { children: { depth: 4, areas: false }, projection: { title: 4, slug: 4, rank: 4, level: 4, path: 4 } } } ]

I even tried passing ‘1’ as it says to do in the docs and still only returns an empty array under the “_children” key when logging out data.

and I have the following in my app.js file: 'apostrophe-pages': { filters: { ancestors: { children: { depth: 4 } }, children: { depth: 4 } },

No matter what I try, I still get “_children: [ ]” back from my logs. How can I get the _children key to populate accurately as my navigation tree shows?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
boutellcommented, Aug 5, 2021

Still looking for a simple test project with steps to reproduce it.

0reactions
yuriislipenkocommented, Aug 5, 2021

Any updates regarding this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is the apostrophe-pages _children array is always empty?
I am trying to get the children of apostrophe pages to appear in my navigation object - however the _children array is always...
Read more >
Empty array in config json file results in null class property
An empty array, object, or dictionary is NOT a 'prefix'. It is a value unto itself. Again, a 'key' with 0 children should...
Read more >
apostrophe-pages
If this array is empty, you cannot add a subpage to a page of ... The action becomes a data-apos-ACTIONGOESHERE attribute on the...
Read more >
Handling JSON null and empty arrays and objects - IBM
This section explains how each of these concepts is mapped to the data object concepts of null and unset. Null values. JSON has...
Read more >
TypeError: Reduce of empty array with no initial value
In JavaScript, there are several reduce functions: ... These functions optionally take an initialValue (which will be used as the first argument to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found