Next.js Discord

Discord Forum

Problem with revalidatePath

Unanswered
Wuchang bream posted this in #help-forum
Open in Discord
Wuchang breamOP
sample code
const Home = () => {
  return (
    <div>
      <Link href="/time" className="border-2 p-2 mx-auto">
        Time
      </Link>
    </div>
  );
};


const Time = async () => {
  const res = await fetch("http://localhost:3000/api");
  const data = res.json();

  return <div>{data}</div>;
};

export default Time;
export const dynamic = "force-dynamic";


export const GET = () => {
  revalidatePath("/time");
  return NextResponse.json(Date.now());
};

As you can see in the video the cache does't change using revalidatePath

0 Replies