text: import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
  
  const cryptoApiHeaders = {
    'x-rapidapi-key': '1596a811bamsh4fe09aafd2a62f2p154bebjsn58ba04c5278e',
    'x-rapidapi-host': 'coinranking1.p.rapidapi.com',
  };
  
  const createRequest = (url) => ({ url, headers: cryptoApiHeaders });
  
  export const cryptoApi = createApi({
    reducerPath: 'cryptoApi',
    baseQuery: fetchBaseQuery({ baseUrl: 'https://coinranking1.p.rapidapi.com' }),
    endpoints: (builder) => ({
      getCryptos: builder.query({
     query: (count) => createRequest(`/coins?limit=${count}`),   //  ?limit=${count}
      }),
      getExchanges: builder.query({
        query: () => createRequest('/exchanges'),
      }),
      getCryptoDetails: builder.query({
        query: (coinId) => createRequest(`/coin/${coinId}`),
      }),
      getCryptoHistory: builder.query({
        query: ({ coinId, timePeriod }) => createRequest(`coin/${coinId}/history/${timePeriod}`),
      }),
    }),
  });
  
  export const { useGetCryptosQuery, useGetCryptoDetailsQuery, useGetExchangesQuery, useGetCryptoHistoryQuery } = cryptoApi;