import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'

export const ImgUploadApi = createApi({
    reducerPath: 'ImgUploadApi',
    // tagTypes: ['Categories'],
    baseQuery: fetchBaseQuery({
         baseUrl: 'http://shop-roles.node.ed.asmer.org.ua/upload',
         prepareHeaders: (headers, { getState }) => {
            // By default, if we have a token in the store, let's use that for authenticated requests
            const token = getState().auth.token;
            if (token) {
              headers.set("Authorization", `Bearer ${token}`);
            }
            return headers;
          }
        }),
    endpoints: (builder) => ({
        setUploadImage: builder.mutation({
          query: (payload) => ({
            method: 'POST',
            body: payload
          }),
        }),
      }),
})

export const {useSetUploadImageMutation} = ImgUploadApi



