RTK Query multiple requests inside injectEndpoints/queryFn reusing other endpoints #2972
-
Hello! I didn't find much documentation about multiple requests with this particular case in mind. I have an endpoint that will get a list of items, and in each item object, there is an id that I have to use to get complete data for another particular object. I don't want to chain multiple Query hooks inside the component, so I'm trying to solve it using the I want to reuse an already-defined endpoint in conjunction with the I have an endpoint called
and now the
This is already working, but I just want some feedback if this is the correct way, or there is a better way to do this. Thank you for reading! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Your solution is creating multiple |
Beta Was this translation helpful? Give feedback.
Your solution is creating multiple
getProfile
cache entries in addition to thatgetData
cache entry - that will also contain the same data. If it works, it works - but honestly I would try to not call one endpoint from another.I'd either have it be all requests or combine multiple hooks into one custom hook.