dilums commited on
Commit
8c823cf
1 Parent(s): 2132a82
app/api/detect/route.ts CHANGED
@@ -49,7 +49,13 @@ export async function POST(request: Request) {
49
  matches.push({ ...item, extract, colorIndex });
50
  }
51
 
52
- const res: DetectResponse = { width, height, matches, labels };
 
 
 
 
 
 
53
  return NextResponse.json(res);
54
  }
55
  }
 
49
  matches.push({ ...item, extract, colorIndex });
50
  }
51
 
52
+ const res: DetectResponse = {
53
+ width,
54
+ height,
55
+ matches,
56
+ labels,
57
+ error: false,
58
+ };
59
  return NextResponse.json(res);
60
  }
61
  }
store/loadData/loadData.ts CHANGED
@@ -17,6 +17,10 @@ export default async function loadData(
17
 
18
  if (response.ok) {
19
  const result: DetectResponse = await response.json();
 
 
 
 
20
  set({
21
  ...result,
22
  loading: false,
 
17
 
18
  if (response.ok) {
19
  const result: DetectResponse = await response.json();
20
+ if (result.error) {
21
+ set({ error: true, loading: false, success: false });
22
+ return;
23
+ }
24
  set({
25
  ...result,
26
  loading: false,
types/types.ts CHANGED
@@ -11,6 +11,7 @@ export type MatchItem = {
11
  };
12
 
13
  export type DetectResponse = {
 
14
  width: number;
15
  height: number;
16
  matches: MatchItem[];
 
11
  };
12
 
13
  export type DetectResponse = {
14
+ error: boolean;
15
  width: number;
16
  height: number;
17
  matches: MatchItem[];