From 123a936f78601fe18fb2e05b9cc0a574a79bf658 Mon Sep 17 00:00:00 2001 From: Hafeez <90968109+hafeezhmha@users.noreply.github.com> Date: Fri, 20 Jun 2025 21:37:14 +0530 Subject: [PATCH] Fix runtime error when API returns null --- ui/app/page.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/app/page.tsx b/ui/app/page.tsx index e5e0fbd..f0dbddb 100644 --- a/ui/app/page.tsx +++ b/ui/app/page.tsx @@ -1,5 +1,4 @@ "use client"; - import { useEffect, useState } from "react"; import { AgentPanel } from "@/components/agent-panel"; import { Chat } from "@/components/chat"; @@ -21,6 +20,8 @@ export default function Home() { useEffect(() => { (async () => { const data = await callChatAPI("", conversationId ?? ""); + if (!data) return; + setConversationId(data.conversation_id); setCurrentAgent(data.current_agent); setContext(data.context); @@ -58,6 +59,11 @@ export default function Home() { setIsLoading(true); const data = await callChatAPI(content, conversationId ?? ""); + + if (!data) { + setIsLoading(false); + return; + } if (!conversationId) setConversationId(data.conversation_id); setCurrentAgent(data.current_agent);