Fix fetch not using error system when unable to fetch

This commit is contained in:
Ethan Lane 2023-10-18 18:15:08 +01:00
parent 9137ddbc0d
commit a64b8dc098

View file

@ -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 {