在線取得をn8nに移動
This commit is contained in:
parent
7e59b8c7bd
commit
c25509c62f
@ -26,11 +26,8 @@ export const useCurrentTrain = () => {
|
||||
export const CurrentTrainProvider = ({ children }) => {
|
||||
const [currentTrain, setCurrentTrain] = useState([]); //現在在線中の全列車 { num: 列車番号, delay: 遅延時分(状態), Pos: 位置情報 }
|
||||
const [currentTrainLoading, setCurrentTrainLoading] = useState("loading"); // success, error, loading
|
||||
const getCurrentTrain = () =>
|
||||
fetch(
|
||||
"https://script.google.com/macros/s/AKfycby9Y2-Bm75J_WkbZimi7iS8v5r9wMa9wtzpdwES9sOGF4i6HIYEJOM60W6gM1gXzt1o/exec",
|
||||
HeaderConfig
|
||||
)
|
||||
const getCurrentTrain = () => {
|
||||
fetch("https://n8n.haruk.in/webhook/c501550c-7d1b-4e50-927b-4429fe18931a")
|
||||
.then((response) => response.json())
|
||||
.then((d) =>
|
||||
d.map((x) => ({ num: x.TrainNum, delay: x.delay, Pos: x.Pos }))
|
||||
@ -40,9 +37,24 @@ export const CurrentTrainProvider = ({ children }) => {
|
||||
setCurrentTrainLoading("success");
|
||||
})
|
||||
.catch(() => {
|
||||
console.log("えらー");
|
||||
setCurrentTrainLoading("error");
|
||||
fetch(
|
||||
"https://script.google.com/macros/s/AKfycby9Y2-Bm75J_WkbZimi7iS8v5r9wMa9wtzpdwES9sOGF4i6HIYEJOM60W6gM1gXzt1o/exec",
|
||||
HeaderConfig
|
||||
)
|
||||
.then((response) => response.json())
|
||||
.then((d) =>
|
||||
d.map((x) => ({ num: x.TrainNum, delay: x.delay, Pos: x.Pos }))
|
||||
)
|
||||
.then((d) => {
|
||||
setCurrentTrain(d);
|
||||
setCurrentTrainLoading("success");
|
||||
})
|
||||
.catch(() => {
|
||||
console.log("えらー");
|
||||
setCurrentTrainLoading("error");
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(getCurrentTrain, []); //初回だけ現在の全在線列車取得
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user