Next.js Discord

Discord Forum

revalidateTag not working if result is empty

Unanswered
Clown posted this in #help-forum
Open in Discord
i am using fetch to fetch some items from my route handler:

const res = await fetch(
    `${process.env.NEXT_PUBLIC_INTERNAL_URL}/api/items/`,
    { headers: headers(), next: { tags: ["fetchItems"] } },
  );

  const it = await res.json();
  const items: Item[] = it;


what i need to do is for nextjs to revalidate the data after i create a new item.
Currently i am using the following in my item creation handler:
revalidateTag("fetchItems");

and then i basically redirect to the page which fetches those items, but the data only revalidates if atleast one item is returned by the fetch. What could be the issue?

1 Reply

Do you have a demo?