From fa0b06cfdcc2dd7539a6143e93a041639f5ed37e Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Mon, 11 Sep 2023 20:50:11 +0100 Subject: [PATCH] Add default value to sortBy variable --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 400567e..f6e7b3c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,8 +10,8 @@ const sortable = [ 'top' ]; -export default async function randomBunny(subreddit: string, sortBy?: string): Promise { - if (!sortBy || !sortable.includes(sortBy)) sortBy = 'hot'; +export default async function randomBunny(subreddit: string, sortBy: string = 'hot'): Promise { + if (!sortable.includes(sortBy)) sortBy = 'hot'; const result = await fetch(`https://reddit.com/r/${subreddit}/${sortBy}.json`);