enzostvs HF Staff commited on
Commit
9e483e7
·
1 Parent(s): bb2648a

handling error correctly

Browse files
Files changed (1) hide show
  1. components/editor/ask-ai/index.tsx +2 -2
components/editor/ask-ai/index.tsx CHANGED
@@ -193,8 +193,8 @@ export function AskAI({
193
 
194
  const isJson =
195
  chunk.trim().startsWith("{") && chunk.trim().endsWith("}");
196
- if (isJson) {
197
- const res = JSON.parse(chunk);
198
  if (res.openLogin) {
199
  setOpen(true);
200
  } else if (res.openSelectProvider) {
 
193
 
194
  const isJson =
195
  chunk.trim().startsWith("{") && chunk.trim().endsWith("}");
196
+ const res = isJson ? JSON.parse(chunk) : null;
197
+ if (res && !res.ok) {
198
  if (res.openLogin) {
199
  setOpen(true);
200
  } else if (res.openSelectProvider) {