<commit_before>import { QueryApi } from './buildThunks';

interface FetchArgs extends RequestInit {
  queryString: string;
}

export function fetchBaseQuery({ baseUrl }: { baseUrl: string }) {
  return async ({ queryString, method = 'GET', ...rest }: FetchArgs, { signal, rejectWithValue }: QueryApi) => {
    const result = await fetch(`${baseUrl}/${queryString}`, {
      method,
      headers: {
        'Content-Type': 'application/json',
      },
      signal,
      ...rest,
    });

    let resultData =
      result.headers.get('Content-Type') === 'application/json' ? await result.json() : await result.text();

    return result.status >= 200 && result.status <= 299
      ? resultData
      : rejectWithValue({ status: result.status, data: resultData });
  };
}
<commit_msg>different response type handling<commit_after>import { QueryApi } from './buildThunks';

interface FetchArgs extends RequestInit {
  queryString: string;
}

export function fetchBaseQuery({ baseUrl }: { baseUrl: string }) {
  return async ({ queryString, method = 'GET', ...rest }: FetchArgs, { signal, rejectWithValue }: QueryApi) => {
    const result = await fetch(`${baseUrl}/${queryString}`, {
      method,
      headers: {
        'Content-Type': 'application/json',
      },
      signal,
      ...rest,
    });

    let resultData =
      result.headers.has('Content-Type') && result.headers.get('Content-Type') !== 'application/json'
        ? await result.text()
        : await result.json();

    return result.status >= 200 && result.status <= 299
      ? resultData
      : rejectWithValue({ status: result.status, data: resultData });
  };
}

{'fraction_non_alphanumeric': 0.155203895313451, 'fraction_numerical': 0.007303712720632989, 'mean_word_length': 3.0794044665012406, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6399241', 'n_tokens_mistral': 486, 'n_tokens_neox': 466, 'n_words': 114}