is it possible to get cookies data on generateStaticParams ?
Unanswered
Barbary Lion posted this in #help-forum
Barbary LionOP
I am working on server side renedering and on the api call there is a body like vendor squad id and user id by which I will fetch the data.
Right I now I am setting the this above data but not able to use it on generateStaticParams as I found out that generateStaticParams doesnot take cookies
is this thing is true or is there any way of doing this
my generateStaticParams code is :-
export async function generateStaticParams() {
const response = await getClientProjectApi({
"vendor_squad_id": cookies.get("squad_id"),
"user_id": cookies.get("user_id"),
"sort_by": "newest_first",
});
return response.allProjects?.data?.map((project: any) => ({
projectid:
project!["project_id"]
}))
}
Right I now I am setting the this above data but not able to use it on generateStaticParams as I found out that generateStaticParams doesnot take cookies
is this thing is true or is there any way of doing this
my generateStaticParams code is :-
export async function generateStaticParams() {
const response = await getClientProjectApi({
"vendor_squad_id": cookies.get("squad_id"),
"user_id": cookies.get("user_id"),
"sort_by": "newest_first",
});
return response.allProjects?.data?.map((project: any) => ({
projectid:
project!["project_id"]
}))
}
1 Reply
generateStaticParams
exists to create pages during build time. So when building them, there is no user. To answer you question: no you can't access the cookies