Skip to content

How I get already fetched data from cache? #4752

@bylly1

Description

@bylly1

I have this conversationApi from where I fetch all user conversations. When user select a conversation the conversation id will be set in url, and message component will fetch the messages. But also, in other components I need to get other informations from the selected conversation. I don t want to pass props to depth (2-3 levels) and I was thinking to get conversation from rtk cache. but my question is how I do that? Should I create another endpoint getConversation or are other ways?

type ConversationQueryParams = Pick<QueryParams, 'q' | 'page'>;

export const conversationApi = api.injectEndpoints({
    endpoints: (builder) => ({
        getConversations: builder.query<
            ConversationProps[],
            ConversationQueryParams | void
        >({
            query: (params) => ({
                url: 'http://localhost:5000/',
                method: 'GET',
                params: params
            }),
        }),
       
    }),
    overrideExisting: false,
});

export const { useGetConversationsQuery } = conversationApi;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions