Skip to content

Working with cache on list #848

Open
@rpayanm

Description

@rpayanm

Package

next-drupal (NPM package)

Ask the question

In the app/page.tsx I have this code:

export default async function Home() {
  const nodes = await drupal.getResourceCollection<DrupalNode[]>(
    "node--article",
    {
      params: {
        "filter[status]": 1,
        "fields[node--article]": "title,path,field_image,uid,created,body",
        include: "field_image,uid",
        sort: "-created",
      },
      next: {
        tags: ['node_list:article'],
      },
    }
  )

  return (
    <>
      <h1 className="mb-10 text-6xl font-black">Latest Articles.</h1>
      {nodes?.length ? (
        nodes.map((node) => (
          <div key={node.id}>
            <ArticleTeaser node={node} />
            <hr className="my-20" />
          </div>
        ))
      ) : (
        <p className="py-4">No nodes found</p>
      )}
    </>
  )
}

I am running npm run preview and I expect that if I create, edit, or delete any article in Drupal, the list on the Next.js app will be updated, but it is not.

How do I accomplish that?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionQuestion asked by a usertriageA new issue that needs triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions