blob: 6d779ed43c4beac6ba0a7fbf532dd6a4fa1c032c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
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;
|