Hello, i keep getting this error, here's my code:
import { Metadata } from "next";
import { createClient } from "../../../prismicio";
import * as prismic from "@prismicio/client";
interface Params {
uid: string
}
export default async function Post({ params }: { params: Params }) {
const client = createClient();
const page = await client.getByUID("post", params.uid);
return <h1>Hello MOM im on TV!!</h1>
}
export async function generateMetadata({
params,
}: {
params: Params;
}): Promise<Metadata> {
const client = createClient();
const page = await client.getByUID("post", params.uid);
return {
title: page.data.meta_title,
description: page.data.meta_description,
};
}
export async function generateStaticParams() {
const client = createClient();
const pages = await client.getAllByType("post");
return pages.map((page) => {
return { uid: page.uid };
});
}
its saying the error is on both client.getAllByType lines
prismicio.ts:
import * as prismic from "@prismicio/client";
import * as prismicNext from "@prismicio/next";
import config from "../slicemachine.config.json";
/**
* The project's Prismic repository name.
*/
export const repositoryName = config.repositoryName;
/**
* A list of Route Resolver objects that define how a document's `url` field is resolved.
*
* {@link https://prismic.io/docs/route-resolver#route-resolver}
*/
// TODO: Update the routes array to match your project's route structure.
const routes: prismic.ClientConfig["routes"] = [
{
type: "homepage",
path: "/",
},
{
type: "post",
path: "blog/:uid",
},
];
/**
* Creates a Prismic client for the project's repository. The client is used to
* query content from the Prismic API.
*
* @param config - Configuration for the Prismic client.
*/
export const createClient = (config: prismicNext.CreateClientConfig = {}) => {
const client = prismic.createClient(repositoryName, {
routes,
fetchOptions:
process.env.NODE_ENV === "production"
? { next: { tags: ["prismic"] }, cache: "force-cache" }
: { next: { revalidate: 5 } },
...config,
});
prismicNext.enableAutoPreviews({
client,
previewData: config.previewData,
req: config.req,
});
return client;
};