From 14dd6bf87f05a411b4eadcb4f6f37f726341a800 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Thu, 17 Nov 2022 23:29:17 +0100 Subject: still have custom if request fails --- webAO/client/fetchLists.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'webAO/client/fetchLists.ts') diff --git a/webAO/client/fetchLists.ts b/webAO/client/fetchLists.ts index bf4fd1b..704c889 100644 --- a/webAO/client/fetchLists.ts +++ b/webAO/client/fetchLists.ts @@ -21,10 +21,6 @@ export const fetchBackgroundList = async () => { export const fetchCharacterList = async () => { try { - const chardata = await request(`${AO_HOST}characters.json`); - const char_array = JSON.parse(chardata); - // the try catch will fail before here when there is no file - const char_select = ( document.getElementById("client_iniselect") ); @@ -32,6 +28,10 @@ export const fetchCharacterList = async () => { char_select.add(new Option("Custom", "0")); + const chardata = await request(`${AO_HOST}characters.json`); + const char_array = JSON.parse(chardata); + // the try catch will fail before here when there is no file + char_array.forEach((character: string) => { char_select.add(new Option(character)); }); @@ -43,10 +43,6 @@ export const fetchCharacterList = async () => { export const fetchEvidenceList = async () => { try { - const evidata = await request(`${AO_HOST}evidence.json`); - const evi_array = JSON.parse(evidata); - // the try catch will fail before here when there is no file - const evi_select = ( document.getElementById("evi_select") ); @@ -54,6 +50,10 @@ export const fetchEvidenceList = async () => { evi_select.add(new Option("Custom", "0")); + const evidata = await request(`${AO_HOST}evidence.json`); + const evi_array = JSON.parse(evidata); + // the try catch will fail before here when there is no file + evi_array.forEach((evi: string) => { evi_select.add(new Option(evi)); }); -- cgit