Skip to content

Commit

Permalink
I don't remember what I did here...
Browse files Browse the repository at this point in the history
  • Loading branch information
cheminfolab committed Apr 6, 2024
1 parent 6d9877e commit 0f6c8f6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
21 changes: 21 additions & 0 deletions frontend/src/context/ChemContext.js
Original file line number Diff line number Diff line change
@@ -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(
<ChemContext.Provider value={contextData}>
{/*{loading ? null : children}*/}
</ChemContext.Provider>
)
}
29 changes: 29 additions & 0 deletions frontend/src/utils/useAxios2.js
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0f6c8f6

Please sign in to comment.