Having problems trying to refresh a server component from the client.
Answered
Large oak-apple gall posted this in #help-forum
Original message was deleted.
Answered by Large oak-apple gall
I had the
revalidatePath call in a client component rather than the server component - it still isn't working but need to rephrase the question. Marking resolved4 Replies
Large oak-apple gall
Here is the code for the client component that actually calls the API endpoint:
import { revalidatePath } from "next/cache";
const createURL = (path: string) => {
return window.location.origin + path;
};
export const createNewEntry = async () => {
const res = await fetch(
new Request(createURL("/api/journal"), {
method: "POST",
})
);
revalidatePath("/journal");
if (res.ok) {
const data = await res.json();
return data.data;
}
};Hmm wait hang on I might have put it in the wrong place ...
Large oak-apple gall
I had the
revalidatePath call in a client component rather than the server component - it still isn't working but need to rephrase the question. Marking resolvedAnswer