Feature/7 migrate to typescript #21
1 changed files with 2 additions and 2 deletions
|
@ -8,8 +8,8 @@ const sortable = [
|
||||||
'top'
|
'top'
|
||||||
];
|
];
|
||||||
|
|
||||||
export default async function randomBunny(subreddit: string, sortBy: string, maxTries = 100): Promise<IFetchResult> {
|
export default async function randomBunny(subreddit: string, sortBy?: string, maxTries = 100): Promise<IFetchResult> {
|
||||||
if (!sortable.includes(sortBy)) sortBy = 'hot';
|
if (!sortBy || !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`);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue