Spaces:
Paused
Paused
matt HOFFNER
commited on
Commit
·
ecb5f4b
1
Parent(s):
79f1edc
tweak
Browse files- src/app/search/web/page.jsx +21 -6
src/app/search/web/page.jsx
CHANGED
@@ -22,16 +22,31 @@ export default function WebSearchPage({ searchParams }) {
|
|
22 |
signal,
|
23 |
});
|
24 |
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
}
|
30 |
|
31 |
-
fetchData()
|
|
|
|
|
32 |
|
33 |
return () => controller.abort();
|
34 |
-
}, [searchParams, searchTerm]);
|
35 |
|
36 |
console.log(aiResponse);
|
37 |
|
|
|
22 |
signal,
|
23 |
});
|
24 |
|
25 |
+
if (!response.ok) {
|
26 |
+
throw new Error(`HTTP error! status: ${response.status}`);
|
27 |
+
} else {
|
28 |
+
// Consume the stream as text
|
29 |
+
let responseText = await response.text();
|
30 |
+
|
31 |
+
// Try to parse the JSON
|
32 |
+
let json;
|
33 |
+
try {
|
34 |
+
json = JSON.parse(responseText);
|
35 |
+
} catch (error) {
|
36 |
+
console.error("Failed to parse JSON", error);
|
37 |
+
}
|
38 |
+
|
39 |
+
console.log(json);
|
40 |
+
setAiResponse(json);
|
41 |
+
}
|
42 |
}
|
43 |
|
44 |
+
fetchData().catch(error => {
|
45 |
+
console.error('Fetch failed: ', error);
|
46 |
+
});
|
47 |
|
48 |
return () => controller.abort();
|
49 |
+
}, [searchParams, searchTerm]);
|
50 |
|
51 |
console.log(aiResponse);
|
52 |
|