diff --git a/frontend/src/context/ChemContext.js b/frontend/src/context/ChemContext.js new file mode 100644 index 0000000..c9066a2 --- /dev/null +++ b/frontend/src/context/ChemContext.js @@ -0,0 +1,21 @@ +import {createContext} from "@types/react"; + +const ChemContext = createContext({}) +export default ChemContext + +export const ChemProvider = ({children}) => { + + let getContainerList + let getContainer + + let contextData = { + // ContainerList:ContainerList, + // Container:Container, + // show:show // in context or on table page? + } + return( + + {/*{loading ? null : children}*/} + + ) +} \ No newline at end of file diff --git a/frontend/src/utils/useAxios2.js b/frontend/src/utils/useAxios2.js new file mode 100644 index 0000000..1509e4c --- /dev/null +++ b/frontend/src/utils/useAxios2.js @@ -0,0 +1,29 @@ +import { useState, useEffect } from 'react'; +import axios from 'axios'; + +axios.defaults.baseURL = 'https://jsonplaceholder.typicode.com'; + +const useAxios2 = (params, authentication=false) => { + const [response, setResponse] = useState(undefined); + const [error, setError] = useState(''); + const [loading, setLoading] = useState(true); + + const fetchData = async params => { + try { + const result = await axios.request(params); + setResponse(result.data); + } catch( error ) { + setError(error); + } finally { + setLoading(false); + } + }; + + useEffect(() => { + fetchData(params); + }, []); // execute once only + + return { response, error, loading }; +}; + +export default useAxios2 \ No newline at end of file