import axios from "../../axios"; import {useState, useEffect, useContext} from 'react'; const useGet = (url, dep) => { console.log(url) const [data, setData] = useState(null); const [isLoading, setIsLoading] = useState(true); const [changed, setChanged] = useState(0) const getData = async (uurl) => { console.log(localStorage.getItem("sessionId")) console.log("url od get " + uurl) await axios.get(uurl, {maxRedirects: 0}).then((res) => { console.log(res); // if(res.request.responseURL.includes('8080')) // { // window.location.href = "/login" // } setData(res.data); }).catch((error) => { console.log(error) // window.location.href = '/error' }) .finally(() => { setIsLoading(false); }); }; useEffect(() => { setIsLoading(true); getData(url); }, [dep, url, changed]); return { data, setData, isLoading, getData, setChanged }; }; export default useGet;