Add default value to sortBy variable #87

Merged
Vylpes merged 1 commit from feature/50-sortBy-variable-default into develop 2023-09-15 15:15:34 +01:00
Showing only changes of commit fa0b06cfdc - Show all commits

View file

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