Fix fetch not using error system when unable to fetch #100
1 changed files with 7 additions and 1 deletions
|
@ -15,7 +15,13 @@ const sortable = [
|
|||
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`);
|
||||
const result = await fetch(`https://reddit.com/r/${subreddit}/${sortBy}.json`)
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch(() => {
|
||||
return null;
|
||||
});
|
||||
|
||||
if (!result) {
|
||||
return {
|
||||
|
|
Loading…
Reference in a new issue