next-drupal
next-drupal copied to clipboard
DrupalNode type definition missing body
DrupalNode type definition is missing the body prop
Hi. Thanks for the feedback.
The reason we don't have a body field on the DrupalNode is because not all node types have a body field.
Example we have some node types using paragraphs and we generally remove the body field.
With that said, you can extend the interface and add your own field pretty easily.
import { DrupalNode } from "next-drupal"
export interface ArticleNode extends DrupalNode {
body: {
value: string
processed: string
format: string
}
field_another_field: string
}
Then you can use it as follows:
const article = await drupal.getResource<ArticleNode>("node--article", ID)
// No error.
article.body.processed
Hope this helps.
Could you provide better documentation about this? I didn't know where to put and how to use what is "explained" under Extending Types at https://next-drupal.org/docs/typescript