From a87b29e961756d48345093ba5290ea69cec64547 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Wed, 27 Mar 2024 14:35:49 +0000 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=BB=8A=E3=83=80=E3=82=A4=E3=83=A4?= =?UTF-8?q?=E3=82=82=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- stateBox/useAllTrainDiagram.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) 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); + }); }); }, []);