fix: disable caching for total post count GROQ queries

This commit is contained in:
Dorian Niemiec 2024-09-07 17:32:09 +02:00
parent b04a49f3e3
commit a51372e7c9
2 changed files with 10 additions and 2 deletions

View file

@ -50,7 +50,11 @@ export async function POST(req: NextRequest) {
const cardsPerPage = 6; const cardsPerPage = 6;
const totalPostsQuery = `count(*[_type == 'blog'])`; const totalPostsQuery = `count(*[_type == 'blog'])`;
const totalPosts: number = await client.fetch(totalPostsQuery); const totalPosts: number = await client.fetch(
totalPostsQuery,
{},
{ cache: "no-store" }
);
const totalPages = Math.ceil(totalPosts / cardsPerPage); const totalPages = Math.ceil(totalPosts / cardsPerPage);
for (let i = 1; i <= totalPages + 1; i++) { for (let i = 1; i <= totalPages + 1; i++) {

View file

@ -48,7 +48,11 @@ const BlogCards: React.FC<BlogCardInterface> = async (props) => {
); );
const totalPostsQuery = `count(*[_type == 'blog'])`; const totalPostsQuery = `count(*[_type == 'blog'])`;
const totalPosts: number = await client.fetch(totalPostsQuery); const totalPosts: number = await client.fetch(
totalPostsQuery,
{},
{ cache: "no-store" }
);
const totalPages = Math.ceil(totalPosts / cardsPerPage); const totalPages = Math.ceil(totalPosts / cardsPerPage);