Hello, I'm using app router, my page has a call to a backend endpoint
Unanswered
Giant wood wasp posted this in #help-forum
Giant wood waspOP
How can I make it the call on each request?. I want to simulate getServerSideProps in page router, because the data changes a lot. Thanks and regards
23 Replies
you just do the db calls in the server component (the
export default async function...)getServerSideProps is removed in app dir and replaced with direct fetching
Giant wood waspOP
I tried that, but the data was cached when I did the app build
so you don't want caching?
Giant wood waspOP
No, I don't
thats an easy fix:
export const dynamic = 'force-dynamic' https://nextjs.org/docs/app/building-your-application/caching#opting-out-2Giant wood waspOP
I want to have always the real data
export const dynamic = 'force-dynamic'
yes, that should do your wishes
Giant wood waspOP
mm ok, I will try that way
Thanks my friend
I forgot a detail, I'm using axios to fetch data, Does that matter?, or is it the same?
that shouldn't change it
Giant wood waspOP
OK, thanks agaim
but: https://www.adios-axios.com (if you use fetch, you will have to make sure that function doesn't cache)
@Giant wood wasp OK, thanks agaim
so it worked 🙂?
Giant wood waspOP
with that it fixed cache: 'no-store'
with fetch
yeah
@riský so it worked 🙂?
Giant wood waspOP
I don't try yet,
I'm working, when have a break I will try it
all good
Giant wood waspOP
Thanks bro