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
Hello!
fetchFirstItem endpoint and fetchItem endpoint are as follows.
fetchFirstItem endpoint: Look up the first item in the item list
fetchItem endpoint: Look up items using a specific item id
For example, the item ID viewed through fetchFirstItem endpoint is 1.
After that, when I import data with item ID 1 to fetchItem endpoint, I want to check the cached data.
I tried to use tags, but I understand that caching data consists of endpoints and parameters, so I worked as follows.
// endpoints
endpoints: (build)=>({fetchFirstItem: build.query({query: ()=>'/items/first',}),fetchItem: build.query({query: (itemId)=>`/items/${itemId}`,}),})// using (in Component)const[fetchFirstItem]=useLazyFetchFirstItem();const[fetchItem]=useLazyFetchItem();constinitItem=async()=>{// I'll bring the first item.constfetchFirstItemResult=awaitfetchFirstItem().unwrap();// fetchItem endpoint is called for caching.constitemId=fetchFirstItemResult.body.itemId;constfetchItemResult=awaitfetchItem(itemId).unwrap();}
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
fetchFirstItem endpoint and fetchItem endpoint are as follows.
For example, the item ID viewed through fetchFirstItem endpoint is 1.
After that, when I import data with item ID 1 to fetchItem endpoint, I want to check the cached data.
I tried to use tags, but I understand that caching data consists of endpoints and parameters, so I worked as follows.
Is there a better way?
Beta Was this translation helpful? Give feedback.
All reactions