Hello Everyone!!
I’m facing a problem while generating static prams in next js for a single post of ghost.
code:
[slug]/page.js:
export async function generateStaticParams() {
try {
const posts = await getPosts();
return posts.map((post) => ({
slug: post.slug,
}));
} catch (error) {
console.log(error);
}
// return [{ tag: "tag1" }, { tag: "tag2" }].map((item) => ({ tag: item.tag }));
}
blogs.js:
import GhostContentAPI from "@tryghost/content-api";
// Create API instance with site credentials
const api = new GhostContentAPI({
url: "http://localhost:2368",
key: "XXX",
version: "v5.0",
});
export async function getPosts() {
return await api.posts
.browse({
limit: "all",
include: "tags"
})
.catch((err) => {
console.error(err);
});
}
The error I’m getting is as:
Also when I normally fetch posts using useEffect of a normal page it works fine.
so can anyone tell me what is the problem?