-
I am making an SWR call to an api and In the query params I am sending a users My issue is the SWR hook is running before context is loading the user's id, meaning that the first SWR call is sending a user Id of undefined, therefore a subsequent SWR call is made. What is the best way I can avoid this happening? Is there a way I can allow context to load before the SWR call is made? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If you want to wait for sending a request until |
Beta Was this translation helpful? Give feedback.
If you want to wait for sending a request until
user_id
has come, you can use the conditional fetching feature by passingnull
as its key.https://swr.vercel.app/docs/conditional-fetching