Filter with multiple checkbox is not working in React(Ts)

Using edamam api to get recipes. I am trying to use filter. It works with single filter but if I use multiple filter, giving error. Error is
react_devtools_backend_compact.js:13851 Error fetching recipes:
AxiosError {message: ‘Request failed with status code 400’, name: ‘AxiosError’, code: ‘ERR_BAD_REQUEST’, config: {…}, request: XMLHttpRequest, …}
code
:
“ERR_BAD_REQUEST”
config
:
{transitional: {…}, adapter: Array(3), transformRequest: Array(1), transformResponse: Array(1), timeout: 0, …}
message
:
“Request failed with status code 400”
name
:
“AxiosError”
request
:
XMLHttpRequest {onreadystatechange: null, readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, …}
response
:
{data: {…}, status: 400, statusText: ”, headers: AxiosHeaders, config: {…}, …}

//components/SearchBar.tsx
"use client"
import PrimaryButton from '@/components/PrimaryButton';
import { Box, Button, Card, CardContent, TextField, Typography } from '@mui/material';
import React, { useState } from 'react';

interface SearchBarProps {
  onSearch: (query: string , filters: { diet: string[] }) => void;
}

const SearchBar: React.FC<SearchBarProps> = ({ onSearch }) => {
  const [query, setQuery] = useState('');
  const [error, setError] = useState('');

  
  // Filter state
  const [dietFilter, setDietFilter] = useState<string[]>([]);

  const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
    e.preventDefault();

    if (!query.trim()) {
      setError('Search query must not be null or empty');
      return;
    }

    setError(''); // Clear error if query is valid
    console.log("Search query:", query); // Debug statement
   
   
    onSearch(query, { diet: dietFilter });
  }; 

  const handleDietChange = (event: React.ChangeEvent<HTMLInputElement>) => {
    const { value, checked } = event.target;
    setDietFilter((prevDietFilter) =>
      checked ? [...prevDietFilter, value] : prevDietFilter.filter((diet) => diet !== value)
    );
  };
  
  return ( 
    <>
    <Box display="flex" justifyContent="center" alignItems="center" minHeight="80vh">
      <Card sx={{ maxWidth: 500, width: '100%', p: 2 }}>
        <CardContent>
          <Typography variant="h6" component="h6" gutterBottom>
              Find the recipe
          </Typography>
              <Box  mt={2} display="flex" alignItems="center">
                <form onSubmit={handleSubmit}>                 
                <TextField
                type="text"
                value={query}
                onChange={(e) => setQuery(e.target.value)}
                placeholder="Search for recipes"
                variant="outlined"
                fullWidth 
                sx={{ mb: 2 }}
                error={Boolean(error)} // Show error state
                helperText={error} // Display the error message
              />
              <Box mb={2}>
              <Typography variant="subtitle1">Diet</Typography>
              <label>
                <input type="checkbox" value="low-carb" onChange={handleDietChange} /> Low-Carb
              </label>
              <label style={{ marginLeft: '10px' }}>
                <input type="checkbox" value="high-protein" onChange={handleDietChange} /> High-Protein
              </label>
            </Box>

                  <PrimaryButton type="submit"  variant="contained">Search</PrimaryButton>
           
                </form>             
              </Box>
              </CardContent>
              </Card>
     
         </Box>
    </>
  );
};

export default SearchBar;
api.tsx
const API_URL = 'https://api.edamam.com/api/recipes/v2';
const APP_ID = process.env.NEXT_PUBLIC_APP_ID;
const APP_KEY = process.env.NEXT_PUBLIC_APP_KEY;

export const fetchRecipes = async (query: string, filters: FetchRecipesFilters = {}): Promise<Recipe[]> => {
  if (!query) {
    throw new Error('Search query must not be null or empty');
  }

  try {
    // Debug: Log the query and filters
    console.log('Query:', query);
    console.log('Filters:', filters);

    const params: Record<string, string> = {
      type: 'public',
      q: query,
      app_id: APP_ID!,
      app_key: APP_KEY!,
    };

    // If diet filters are provided, add them to the params
    if (filters.diet && filters.diet.length > 0) {
      params.diet = filters.diet.join(','); // Join filters with a comma
    }


     // Debug: Log the params being sent to the API
     console.log('Request Params:', params);

     const response = await axios.get<ApiResponse>(API_URL, {
       params,
     });
 

    if (!response.data.hits) {
      throw new Error('No recipes found');
    }

    return response.data.hits.map((hit) => hit.recipe);
  } catch (error) {
    console.error('Error fetching recipes:', error);
    
    return [];
  }
};
searchcontent
interface RecipeProp {
  uri: string;
  label: string;
  image: string;
  images: Images;
  ingredientLines: string[];
  }
  

  export default function RecipeSearchContent() {
    const [recipes, setRecipes] = React.useState<RecipeProp[]>([]);
    const [isMounted, setIsMounted] = useState(true);

    useEffect(() => {
      setIsMounted(true);
  
      return () => {
        setIsMounted(false);
      };
    }, []);
  
    const handleSearch = useCallback(async (query: string ,  filters: FetchRecipesFilters) => {
      try {
        // Fetch recipes from the API
        const results: RecipeProp[] = await fetchRecipes(query, filters);
  
        // If the component is still mounted, update the state
        if (isMounted) {
          setRecipes(results);
        }
      } catch (error) {
        console.error("Error fetching recipes:", error);
      }
    }, [isMounted]);
  
  

    return (
      <Container>
        <SearchBar onSearch={handleSearch} />
        <RecipeListContent recipes={recipes} />
      </Container>
    );
  }

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật