fix(room): fix model/ai list response parsing in RoomSettingsPanel
The SDK wraps API responses as { data: { code, message, data: [...] } }.
Code was incorrectly accessing resp.data['200'] which doesn't exist.
Fix to use resp.data.data to reach the actual array.
This commit is contained in:
parent
4f1ea95b58
commit
5ff45770ec
@ -68,8 +68,8 @@ export const RoomSettingsPanel = memo(function RoomSettingsPanel({
|
|||||||
setAiConfigsLoading(true);
|
setAiConfigsLoading(true);
|
||||||
try {
|
try {
|
||||||
const resp = await aiList({ path: { room_id: room.id } });
|
const resp = await aiList({ path: { room_id: room.id } });
|
||||||
const inner = (resp.data as Record<string, unknown>)?.['200'] as Record<string, unknown> | undefined;
|
const inner = resp.data as { data?: RoomAiResponse[] } | undefined;
|
||||||
setAiConfigs(Array.isArray(inner?.['data']) ? (inner['data'] as RoomAiResponse[]) : []);
|
setAiConfigs(Array.isArray(inner?.data) ? inner.data : []);
|
||||||
} catch {
|
} catch {
|
||||||
// ignore
|
// ignore
|
||||||
} finally {
|
} finally {
|
||||||
@ -86,8 +86,8 @@ export const RoomSettingsPanel = memo(function RoomSettingsPanel({
|
|||||||
setModelsLoading(true);
|
setModelsLoading(true);
|
||||||
try {
|
try {
|
||||||
const resp = await modelList({});
|
const resp = await modelList({});
|
||||||
const raw = resp.data as Record<string, unknown> | undefined;
|
const inner = resp.data as { data?: ModelResponse[] } | undefined;
|
||||||
setAvailableModels(Array.isArray(raw?.['200']) ? (raw['200'] as ModelResponse[]) : []);
|
setAvailableModels(Array.isArray(inner?.data) ? inner.data : []);
|
||||||
} catch {
|
} catch {
|
||||||
toast.error('Failed to load models');
|
toast.error('Failed to load models');
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user