Add default value to sortBy variable
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Ethan Lane 2023-09-11 20:50:11 +01:00
parent e10bdaf115
commit fa0b06cfdc

View file

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