aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Matei Pintilie <lucafulger@gmail.com>2021-11-28 19:01:49 +0000
committerLuca Matei Pintilie <lucafulger@gmail.com>2021-11-28 19:01:49 +0000
commit5a137ce1370dd1dd49a45fff739a2e6c8f259ef5 (patch)
treed0f30345b1c168b684ec01006566f8455b109eb8
parent6c29c2c134f069f247e3a9cd7a361405d38b159f (diff)
downloadspeedrunbot-slash-5a137ce1370dd1dd49a45fff739a2e6c8f259ef5.tar
speedrunbot-slash-5a137ce1370dd1dd49a45fff739a2e6c8f259ef5.tar.gz
speedrunbot-slash-5a137ce1370dd1dd49a45fff739a2e6c8f259ef5.tar.bz2
speedrunbot-slash-5a137ce1370dd1dd49a45fff739a2e6c8f259ef5.tar.lz
speedrunbot-slash-5a137ce1370dd1dd49a45fff739a2e6c8f259ef5.tar.xz
speedrunbot-slash-5a137ce1370dd1dd49a45fff739a2e6c8f259ef5.tar.zst
speedrunbot-slash-5a137ce1370dd1dd49a45fff739a2e6c8f259ef5.zip
If an option is empty then don't return anything
-rwxr-xr-xsrc/srcom/utils.ts2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/srcom/utils.ts b/src/srcom/utils.ts
index c4dd843..a3cc8fe 100755
--- a/src/srcom/utils.ts
+++ b/src/srcom/utils.ts
@@ -24,6 +24,7 @@ interface ApiArrayResponse {
export async function getUser(
query: string,
): Promise<SpeedrunCom.User | false> {
+ if (!query.length) return false;
let res: Response;
res = await fetch(`${SRC_API}/users?lookup=${encodeURI(query)}`);
const data = (await res.json()).data as SpeedrunCom.User[];
@@ -38,6 +39,7 @@ export async function getUser(
export async function getGame(
query: string,
): Promise<SpeedrunCom.Game | false> {
+ if (!query.length) return false;
let res: Response;
res = await fetch(`${SRC_API}/games?abbreviation=${query}`);
const data = (await res.json()).data as SpeedrunCom.Game[];