You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

postsApiSlice.js 445B

123456789101112131415161718
  1. import { apiSlice } from "@features/api/apiSlice";
  2. export const postsApiSlice = apiSlice.injectEndpoints({
  3. endpoints: (builder) => ({
  4. allPosts: builder.query({
  5. query: () => ({
  6. url: "/posts?populate=*",
  7. }),
  8. }),
  9. singlePost: builder.query({
  10. query: (postId) => ({
  11. url: `/posts/${postId}?populate=*`,
  12. }),
  13. }),
  14. }),
  15. });
  16. export const { useAllPostsQuery, useSinglePostQuery } = postsApiSlice;