How to use generateStaticParams with trpc?

I'm going to use generateStaticParams with trpc but it throw me an error.
No description
No description
10 Replies
xytunghoanh
xytunghoanhOP•9mo ago
"ct3aMetadata": { "initVersion": "7.29.0" }
FleetAdmiralJakob 🗕 🗗 🗙
why do you want to query the posts from the server in the first place?
Rhys
Rhys•9mo ago
Is this in pages router? Looks like you're calling app router code from pages
xytunghoanh
xytunghoanhOP•9mo ago
yes. it's app router i use it for ssg all post fom db
Rhys
Rhys•9mo ago
Uhhh it might be because generateStaticParams isn't a part of the request context So there's no headers() which is called from tRPC headers() relies on asynclocalstorage which is created on a per request basis If you just call your getAllPosts function directly that'll work
xytunghoanh
xytunghoanhOP•9mo ago
i saw headers() in createContext function with out async await?
Rhys
Rhys•9mo ago
async await is fine that should still work
xytunghoanh
xytunghoanhOP•9mo ago
oh. i will call directly prisma to query without tprc but if i call directly prisma without trpc router. it works with no one error
Rhys
Rhys•9mo ago
yeah don't you want it to work? tRPC calls headers() which is causing the problem
xytunghoanh
xytunghoanhOP•9mo ago
🥲🥲. Ok i think i have a solution thanks
Want results from more Discord servers?
Add your server