Skip to content

Commit

Permalink
test(fe): show error message (#1457)
Browse files Browse the repository at this point in the history
* chore(fe): log fetched data

* test(fe): show error message
  • Loading branch information
aintbe authored Feb 21, 2024
1 parent 0528797 commit a7ea86b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions frontend-client/app/(main)/problem/_components/ProblemTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ interface Props {
}

export default async function ProblemTable({ search, order }: Props) {
const { problems }: { problems: Problem[] } = await fetcher
.get('problem', {
const res:
| { problems: Problem[] }
| { message: string; error: string; statusCode: number } = await fetcher
.get('problem/2342', {
searchParams: {
take: 10,
search,
Expand All @@ -19,9 +21,12 @@ export default async function ProblemTable({ search, order }: Props) {
})
.json()

if (!('problems' in res)) {
throw new Error(`${res.statusCode} ${res.error}: ${res.message}`)
}
return (
<DataTable
data={problems}
data={res.problems}
columns={columns}
headerStyle={{
title: 'text-left w-5/12',
Expand Down

0 comments on commit a7ea86b

Please sign in to comment.