Files
jrshikoku/lib/getStationList2.js
2022-10-09 00:03:45 +09:00

56 lines
1.6 KiB
JavaScript

let status = undefined;
export const getStationList2 = async (props) => {
if (status) return status;
const HeaderConfig = {
headers: { referer: "https://train.jr-shikoku.co.jp/sp.html" },
};
return await Promise.all([
fetch(
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=yosan",
HeaderConfig
).then((response) => response.json()),
fetch(
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=uwajima",
HeaderConfig
).then((response) => response.json()),
fetch(
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=uwajima2",
HeaderConfig
).then((response) => response.json()),
fetch(
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=dosan",
HeaderConfig
).then((response) => response.json()),
fetch(
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=dosan2",
HeaderConfig
).then((response) => response.json()),
fetch(
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=koutoku",
HeaderConfig
).then((response) => response.json()),
fetch(
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=tokushima",
HeaderConfig
).then((response) => response.json()),
fetch(
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=naruto",
HeaderConfig
).then((response) => response.json()),
]).then((values) => {
let stationList = {};
[
stationList.yosan,
stationList.uwajima,
stationList.uwajima2,
stationList.dosan,
stationList.dosan2,
stationList.koutoku,
stationList.tokushima,
stationList.naruto,
] = values;
return stationList;
});
};