Sharing data between generatestaticparams and page component
Unanswered
West African Lion posted this in #help-forum
West African LionOP
I am making an api call inside the generatestatic params to fetch location and returning locationname in the slug. However to make an api call inside the Page component I need location id.
How can I share the data from generatestaticparams to page?
If I make request outside the generatestaticparams and page , it is being called multiple times.
#nextjs #approuter #generatestaticparams
How can I share the data from generatestaticparams to page?
If I make request outside the generatestaticparams and page , it is being called multiple times.
#nextjs #approuter #generatestaticparams
3 Replies
Original message was deleted
West African LionOP
@West African Lion I am making an api call inside the generatestatic params to fetch location and returning locationname in the slug. However to make an api call inside the Page component I need location id.
How can I share the data from generatestaticparams to page?
If I make request outside the generatestaticparams and page , it is being called multiple times.
#nextjs #approuter #generatestaticparams
you can wrap your function inside a
React.cache(() => { your code here })
to call your function only once per request@West African Lion solved?