get correct text in json
This commit is contained in:
1 parent
3e3749ebd5
commit
045fa89053
1 file changed
+4
-2
@@ -51,8 +51,10 @@ export async function POST(req) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.text();
|
const data = await response.json();
|
||||||
return new Response(JSON.stringify({ answer: data }), { status: 200 });
|
const answer = data?.choices?.[0]?.message?.content || "No answer found";
|
||||||
|
|
||||||
|
return new Response(JSON.stringify({ answer }), { status: 200 });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Backend error:", error);
|
console.error("Backend error:", error);
|
||||||
return new Response(
|
return new Response(
|
||||||
|
|||||||
Reference in new issue
Block a user