I want to utilise the interface with data returned from useMutation hooks in component, provided from RTK Query. how can I achive this.
Refer to code below:
In API Slice.
export const catsApi: any = createApi({
reducerPath: 'catsApi',
baseQuery: baseQueryWithReauth,
endpoints: (builder) => ({
fetchCats: builder.query<IGenericResponse<ICatResponse>, any>({
query: () => ({
url: `cats`,
method: "GET",
}),
}),
}),
});
In component
const { isLoading: catsLoading, data: cats} = useFetchCatsQuery();
useEffect(() => {
const catName = cats.<here i need keys from my ICatResponse>
}, [someDependancy]);
In component
const { isLoading: catsLoading, data: cats} = useFetchCatsQuery();