import { rootApi } from '@/app/rootApi' type Quote = { id: number quote: string author: string } type QuotesApiResponse = { quotes: Quote[] total: number skip: number limit: number } // Define a service using a base URL and expected endpoints export const quotesApiSlice = rootApi.injectEndpoints({ // Tag types are used for caching and invalidation. endpoints: (build) => ({ // Supply generics for the return type (in this case `QuotesApiResponse`) // and the expected query argument. If there is no argument, use `void` // for the argument type instead. getQuotes: build.query({ query: (limit = 10) => ({ url: `?limit=${limit.toString()}`, method: 'GET', }), // `providesTags` determines which 'tag' is attached to the // cached data returned by the query. }), }), }) // Hooks are auto-generated by RTK-Query // Same as `quotesApiSlice.endpoints.getQuotes.useQuery` export const { useGetQuotesQuery } = quotesApiSlice