mirror of
https://github.com/ershisan99/flashcards-example-project.git
synced 2025-12-27 12:34:11 +00:00
lesson 3 in progress
This commit is contained in:
@@ -1 +0,0 @@
|
||||
export * from './auth.ts'
|
||||
@@ -1,9 +1,9 @@
|
||||
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'
|
||||
|
||||
export const api = createApi({
|
||||
reducerPath: 'api',
|
||||
export const baseApi = createApi({
|
||||
reducerPath: 'baseApi',
|
||||
baseQuery: fetchBaseQuery({
|
||||
baseUrl: 'http://localhost:3333',
|
||||
baseUrl: 'https://api.flashcards.andrii.es',
|
||||
credentials: 'include',
|
||||
prepareHeaders: headers => {
|
||||
headers.append('x-auth-skip', 'true')
|
||||
@@ -11,11 +11,11 @@ export const api = createApi({
|
||||
}),
|
||||
endpoints: builder => {
|
||||
return {
|
||||
getMe: builder.query<any, void>({
|
||||
getDecks: builder.query<any, void>({
|
||||
query: () => `v1/decks`,
|
||||
}),
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
export const { useGetMeQuery } = api
|
||||
export const { useGetDecksQuery } = baseApi
|
||||
@@ -1,13 +1,16 @@
|
||||
import { configureStore } from '@reduxjs/toolkit'
|
||||
import { setupListeners } from '@reduxjs/toolkit/query/react'
|
||||
|
||||
import { api } from '@/services/auth'
|
||||
import { baseApi } from './base-api'
|
||||
|
||||
export const store = configureStore({
|
||||
reducer: {
|
||||
[api.reducerPath]: api.reducer,
|
||||
[baseApi.reducerPath]: baseApi.reducer,
|
||||
},
|
||||
middleware: getDefaultMiddleware => getDefaultMiddleware().concat(api.middleware),
|
||||
middleware: getDefaultMiddleware => getDefaultMiddleware().concat(baseApi.middleware),
|
||||
})
|
||||
|
||||
export type AppDispatch = typeof store.dispatch
|
||||
export type RootState = ReturnType<typeof store.getState>
|
||||
|
||||
setupListeners(store.dispatch)
|
||||
|
||||
Reference in New Issue
Block a user