<commit_before>import React, { useState } from 'react';
import { Select, TextInput, Button } from '@mantine/core';
import { errorMessage } from 'app/libs/notification';
import {
  ACTION,
  dispatch,
  useQueryBuilderContext,
} from 'app/pages/querybuilder/context/query-builder-provider';
import { Container, Content } from 'app/components';

function send(method, url, query) {
  dispatch(ACTION.SET_HTTP, { loading: true });
  fetch(url, {
    method,
    headers: { 'Content-Type': 'application/json;charset=utf-8' },
    body: query,
  })
    .then((response) => response.json())
    .then((result) =>
      dispatch(ACTION.SET_HTTP, {
        response: JSON.stringify(result, null, 4),
      })
    )
    .catch((error) => {
      errorMessage(error.message);
      dispatch(ACTION.SET_HTTP, {});
    });
}

export default function QueryEndpoint() {
  const httpMethods = ['POST', 'GET'];
  const [method, setMethod] = useState('POST');
  const [url, setUrl] = useState('http://localhost:8080/search/');
  const query = useQueryBuilderContext((ctx) => ctx.query.input);
  const loading = useQueryBuilderContext((ctx) => ctx.http.loading);

  return (
    <Content>
      <Container sx={{ gridTemplateColumns: 'max-content auto max-content' }}><commit_msg>Do not set request body when doing GET<commit_after>import React, { useState } from 'react';
import { Select, TextInput, Button } from '@mantine/core';
import { errorMessage } from 'app/libs/notification';
import {
  ACTION,
  dispatch,
  useQueryBuilderContext,
} from 'app/pages/querybuilder/context/query-builder-provider';
import { Container, Content } from 'app/components';

function send(method, url, query) {
  dispatch(ACTION.SET_HTTP, { loading: true });
  fetch(url, {
    method,
    headers: { 'Content-Type': 'application/json;charset=utf-8' },
    body: method === 'POST' ? query : null,
  })
    .then((response) => response.json())
    .then((result) =>
      dispatch(ACTION.SET_HTTP, {
        response: JSON.stringify(result, null, 4),
      })
    )
    .catch((error) => {
      errorMessage(error.message);
      dispatch(ACTION.SET_HTTP, {});
    });
}

export default function QueryEndpoint() {
  const httpMethods = ['POST', 'GET'];
  const [method, setMethod] = useState('POST');
  const [url, setUrl] = useState('http://localhost:8080/search/');
  const query = useQueryBuilderContext((ctx) => ctx.query.input);
  const loading = useQueryBuilderContext((ctx) => ctx.http.loading);

  return (
    <Content>
      <Container sx={{ gridTemplateColumns: 'max-content auto max-content' }}>
{'fraction_non_alphanumeric': 0.16122766122766122, 'fraction_numerical': 0.004662004662004662, 'mean_word_length': 3.971042471042471, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, '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': '5453739', 'n_tokens_mistral': 787, 'n_tokens_neox': 780, 'n_words': 176}