Not able to access paragraphs data
See original GitHub issueHi, first and foremost, thanks for a great integration with Drupal!
We’re trying this out and we’re running into issues when trying to populate paragraphs data to our basic pages.
In [...slug].tsx
we’re including field_content
which holds all our paragraphs:
if (type === "node--page") {
params = {
include: "field_content",
}
}
When we console.log our response
(the entire node data) we can see that there is a paragraph called paragraph--hero
which is good. But we can’t access the data nested inside the paragraph:
When we check our api-response locally (http://localhost/jsonapi/node/page?include=field_content
), we can see that our nested paragraph data lives inside the included
part of the response:
Sadly the included
part is not available to us when we console log the entire node data:
Does anyone have a solution or know how to access the nested data? We need this to be able to build dynamic pages.
Issue Analytics
- State:
- Created a year ago
- Comments:14
Top GitHub Comments
Hi again @shadcn!
I continued to investigate this yesterday and it seems like I hadn’t configured the module
Paragraphs Type Permissions
properly.After I configured that anonymous users would be able to view my Hero paragraph, the data is now showing up in my response.
Thanks for all your help and feedback!
Just dropping this here in case anyone else needs help with this. I don’t have any Paragraph Type permissions added to my Drupal site. I was able to access my Paragraph and the Media asset within it with the following:
My paragraphs field is Body variation with a Paragraph Type of Image and body text which has an image, a select field for image position (above, left or right) and the Body continued field.
For the
include
on mynode--article
type ingetStaticProps
This gives me all three fields in my response. If I just add
field_body_variation
without the.field_image_asset.field_media_image
I’m not able to see the path to the asset in the Media Library in my response.I got stuck on this while trying to use Paragraphs that use Media assets (as opposed to a simple Image field). Hope this helps someone.