text: import { createApi, fetchBaseQuery } from "@reduxjs/toolkit/query/react";
  
  const baseUrl = "https://bing-news-search1.p.rapidapi.com";
  const cryptoNewsHeaders = {
    "x-bingapis-sdk": "true",
    "x-rapidapi-host": "bing-news-search1.p.rapidapi.com",
    "x-rapidapi-key": "c4314d37fbmshf97f38cb38d2e81p1df0dfjsnaffc99eadd9c",
  };
  
  const createRequest = (url) => ({ url, headers: cryptoNewsHeaders });
  
  export const cryptoNewsApi = createApi({
    reducerPath: "cryptoNewsApi",
    baseQuery: fetchBaseQuery({ baseUrl }),
    endpoints: (builder) => ({
      getCryptoNews: builder.query({
        query: ({ newsCategory, count }) =>
          createRequest(
            `/news/search?q=${newsCategory}&safeSearch=Off&textFormat=Raw&freshness=Day&count=${count}`
          ),
      }),
    }),
  });
  
  export const { useGetCryptoNewsQuery } = cryptoNewsApi;
  