Make sortBy optional

This commit is contained in:
Ethan Lane 2021-12-01 20:53:45 +00:00
parent d32b44052c
commit dbf1d03524
Signed by: Vylpes
GPG key ID: EED233CC06D12504

View file

@ -8,8 +8,8 @@ const sortable = [
'top'
];
export default async function randomBunny(subreddit: string, sortBy: string, maxTries = 100): Promise<IFetchResult> {
if (!sortable.includes(sortBy)) sortBy = 'hot';
export default async function randomBunny(subreddit: string, sortBy?: string, maxTries = 100): Promise<IFetchResult> {
if (!sortBy || !sortable.includes(sortBy)) sortBy = 'hot';
const result = await fetch(`https://reddit.com/r/${subreddit}/${sortBy}.json`);