Fix fetch not using error system when unable to fetch
This commit is contained in:
parent
9137ddbc0d
commit
a64b8dc098
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> {
|
export default async function randomBunny(subreddit: string, sortBy: string = 'hot'): Promise<IReturnResult> {
|
||||||
if (!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`)
|
||||||
|
.then((res) => {
|
||||||
|
return res;
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue