You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi guys. I'm having trouble understanding how to use the fetcher aspect of useSWR in a dynamic Next.js page as a new developer. My API calls are abstracted out in other functions, and that response data is then processed in additional functions (for reasons such as formatting strings before calling as props to render and to call subsequent API's based on the data) before being returned to awaiting variables in the page's getStaticProps that are part of a promise chain. Should I be designing my code differently? Some of the API fetches require inputs that are cross-checked from another API, and based on the page slug, so I'm unable to call them straight away. The useSWR examples I've seen all show fetching from an endpoint and immediately using the data in page render. What is the best practice in terms of processing response data? Should I be using a global state or somehow create my own endpoints to organize data after processing and call SWR? Thanks!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi guys. I'm having trouble understanding how to use the fetcher aspect of useSWR in a dynamic Next.js page as a new developer. My API calls are abstracted out in other functions, and that response data is then processed in additional functions (for reasons such as formatting strings before calling as props to render and to call subsequent API's based on the data) before being returned to awaiting variables in the page's getStaticProps that are part of a promise chain. Should I be designing my code differently? Some of the API fetches require inputs that are cross-checked from another API, and based on the page slug, so I'm unable to call them straight away. The useSWR examples I've seen all show fetching from an endpoint and immediately using the data in page render. What is the best practice in terms of processing response data? Should I be using a global state or somehow create my own endpoints to organize data after processing and call SWR? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions