diff --git a/stateBox/useAllTrainDiagram.js b/stateBox/useAllTrainDiagram.js index f4f5158..dde9af8 100644 --- a/stateBox/useAllTrainDiagram.js +++ b/stateBox/useAllTrainDiagram.js @@ -12,11 +12,10 @@ export const useAllTrainDiagram = () => { export const AllTrainDiagramProvider = ({ children }) => { const [allTrainDiagram, setAllTrainDiagram] = useState(); - const customData = { - }; + const customData = {}; useEffect(() => { fetch( - "https://script.google.com/macros/s/AKfycbx_s7RB-xTy-iAslFJg7LfplLV09-hjDXEjdi9kCP_JT45wq17Af_IPOKIOqIfaNDg/exec" + "http://n8n.haruk.in/webhook/CrowdTh%E2%82%AC71m3Ra7!ngLead%E2%82%ACr$" ) .then((res) => res.json()) .then((res) => { @@ -30,6 +29,24 @@ export const AllTrainDiagramProvider = ({ children }) => { .then((res) => { Object.assign(res, customData); setAllTrainDiagram(res); + }) + .catch((d) => { + fetch( + "https://script.google.com/macros/s/AKfycbx_s7RB-xTy-iAslFJg7LfplLV09-hjDXEjdi9kCP_JT45wq17Af_IPOKIOqIfaNDg/exec" + ) + .then((res) => res.json()) + .then((res) => { + const data = {}; + res.forEach((d) => { + const keys = Object.keys(d); + data[keys] = d[keys]; + }); + return data; + }) + .then((res) => { + Object.assign(res, customData); + setAllTrainDiagram(res); + }); }); }, []);