import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'; export const apiSlice = createApi({ reducerPath: 'api', baseQuery: fetchBaseQuery({ baseUrl: 'http://localhost:3000' }), tagTypes: ['Guests'], endpoints: builder => ({ getGuests: builder.query({ query: () => '/guests', providesTags: ['Guests'] }), updateGuest: builder.mutation({ query: guest => ({ url: `/guests/${guest.id}`, method: 'PATCH', body: guest, providesTags: ['Guests'] }) }) }) }); export const { useGetGuestsQuery, useUpdateGuestMutation } = apiSlice;