How can I retrieve only filtered paths from getStaticPaths
?
This function currently returns all posts
export async function getStaticPaths() {
const { data } = await axios.get(`${url}/category`, config);
const paths = data.map((post) => {
return {
params: { postId: post.id },
};
});
return {
paths,
fallback: false
}
}
Here is my revised code
export async function getStaticPaths() {
const { data } = await axios.get(`${url}/category`, config);
const paths = data.filter((post) => {
if (post.isActive) {
return { params: { postId: post.id } }
}
})
return {
paths,
fallback: false
}
}
The error message received:
> Build error occurred
Error: Additional keys were returned from `getStaticPaths` in page "/product/[packageAlias]". URL Parameters intended for this dynamic route must be nested under the `params` key,