From dbf1d035249e6d146deb848f71ef2f9c7af986c5 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Wed, 1 Dec 2021 20:53:45 +0000 Subject: [PATCH] Make sortBy optional --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index dac6857..f61a93a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,8 +8,8 @@ const sortable = [ 'top' ]; -export default async function randomBunny(subreddit: string, sortBy: string, maxTries = 100): Promise { - if (!sortable.includes(sortBy)) sortBy = 'hot'; +export default async function randomBunny(subreddit: string, sortBy?: string, maxTries = 100): Promise { + if (!sortBy || !sortable.includes(sortBy)) sortBy = 'hot'; const result = await fetch(`https://reddit.com/r/${subreddit}/${sortBy}.json`);