Skip to content

Commit

Permalink
handle cats api error
Browse files Browse the repository at this point in the history
  • Loading branch information
sitek94 committed Nov 25, 2023
1 parent dfa0ca7 commit ffe8fc6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions apps/remix/app/routes/_index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ export const meta: MetaFunction = () => {
}

export const loader = async () => {
const { data: cats } = await catsApi.getAll()

return json({ cats })
try {
const { data: cats } = await catsApi.getAll()
return json({ cats })
} catch (error) {
console.log(`Error fetching cats: ${error}`)
return json({ cats: [] })
}
}

export default function Index() {
Expand Down

0 comments on commit ffe8fc6

Please sign in to comment.