text: import {useState, useEffect} from 'react'
  import axios from 'axios'
  import { API_URL } from '../components/mainpages/utils/config'
  
  
  function ProductsAPI() {
      const [products, setProducts] = useState([])
      const [callback, setCallback] = useState(false)
      const [category, setCategory] = useState('')
      const [sort, setSort] = useState('')
      const [search, setSearch] = useState('')
      const [page, setPage] = useState(1)
      const [result, setResult] = useState(0)
  
      useEffect(() =>{
          const getProducts = async () => {
  
              const res = await axios.get(`${API_URL}/api/products/?${sort}&page=${page}&limit=${9*page}&title=${search}&${category}`)
              
              setProducts(res.data.products)
              setResult(res.data.result)
          }
          getProducts()
      },[callback, category, sort, search, page])
      
      return {
          products: [products, setProducts],
          callback: [callback, setCallback],
          category: [category, setCategory],
          sort: [sort, setSort],
          search: [search, setSearch],
          page: [page, setPage],
          result: [result, setResult]
      }
  }
  
  export default ProductsAPI
  