Seeing if redux tookit query is caching the endpoint

This commit is contained in:
Frank
2023-10-04 18:50:14 -06:00
parent 32259af266
commit 01db3125e0
2 changed files with 12 additions and 5 deletions

View File

@@ -10,12 +10,15 @@ export const pagesApi: any = createApi({
return action.payload[reducerPath]
}
},
tagTypes: ['Pages'],
endpoints: (builder) => ({
getPages: builder.query({
query: () => `/pages${WORDPRESS_POSTS_FIELD_FILTERS}`
query: () => `/pages${WORDPRESS_POSTS_FIELD_FILTERS}`,
providesTags: ['Pages'],
}),
getPage: builder.query({
query: (slug) => `/pages${WORDPRESS_POST_FIELD_FILTERS}&slug=${slug}`
query: (slug) => `/pages${WORDPRESS_POST_FIELD_FILTERS}&slug=${slug}`,
providesTags: ['Pages'],
})
})
});

View File

@@ -10,15 +10,19 @@ export const postsApi: any = createApi({
return action.payload[reducerPath]
}
},
tagTypes: ['Posts', 'Image', 'Post'],
endpoints: (builder) => ({
getPostImage: builder.query({
query: (imageID) => `/media/${imageID}`
query: (imageID) => `/media/${imageID}`,
providesTags: ['Image'],
}),
getPosts: builder.query({
query: () => `/posts${WORDPRESS_POSTS_FIELD_FILTERS}`
query: () => `/posts${WORDPRESS_POSTS_FIELD_FILTERS}`,
providesTags: ['Posts'],
}),
getPost: builder.query({
query: (slug) => `/posts${WORDPRESS_POST_FIELD_FILTERS}&slug=${slug}`
query: (slug) => `/posts${WORDPRESS_POST_FIELD_FILTERS}&slug=${slug}`,
providesTags: ['Posts'],
})
})
});