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.

authApiSlice.js 816B

123456789101112131415161718192021222324252627282930
  1. import { apiSlice } from "@features/api/apiSlice";
  2. export const authApiSlice = apiSlice.injectEndpoints({
  3. endpoints: (builder) => ({
  4. login: builder.mutation({
  5. providesTags: ["User"],
  6. query: (credentials) => ({
  7. url: "/auth/local",
  8. method: "POST",
  9. body: { ...credentials },
  10. }),
  11. }),
  12. register: builder.mutation({
  13. query: (credentials) => ({
  14. url: "/auth/local/register",
  15. method: "POST",
  16. body: { ...credentials },
  17. }),
  18. }),
  19. authProvider: builder.mutation({
  20. query: ({ provider, accessToken }) => ({
  21. url: `/auth/${provider}/callback?access_token=${accessToken}`,
  22. method: 'GET'
  23. }),
  24. }),
  25. }),
  26. });
  27. export const { useLoginMutation, useRegisterMutation, useAuthProviderMutation } =
  28. authApiSlice;