fdeniz's picture
Initial commit with current state
5491d8f
raw
history blame contribute delete
450 Bytes
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
export const api = createApi({
reducerPath: 'api',
baseQuery: fetchBaseQuery({
baseUrl: import.meta.env.VITE_API_BASE_URL,
prepareHeaders: (headers, { getState }) => {
const token = getState().app.authToken;
if (token) {
headers.set('Authorization', `Bearer ${token}`);
}
return headers;
},
}),
endpoints: () => ({}),
});