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);
|
||||
try {
|
||||
const resp = await aiList({ path: { room_id: room.id } });
|
||||
const inner = (resp.data as Record<string, unknown>)?.['200'] as Record<string, unknown> | undefined;
|
||||
setAiConfigs(Array.isArray(inner?.['data']) ? (inner['data'] as RoomAiResponse[]) : []);
|
||||
const inner = resp.data as { data?: RoomAiResponse[] } | undefined;
|
||||
setAiConfigs(Array.isArray(inner?.data) ? inner.data : []);
|
||||
} catch {
|
||||
// ignore
|
||||
} finally {
|
||||
@ -86,8 +86,8 @@ export const RoomSettingsPanel = memo(function RoomSettingsPanel({
|
||||
setModelsLoading(true);
|
||||
try {
|
||||
const resp = await modelList({});
|
||||
const raw = resp.data as Record<string, unknown> | undefined;
|
||||
setAvailableModels(Array.isArray(raw?.['200']) ? (raw['200'] as ModelResponse[]) : []);
|
||||
const inner = resp.data as { data?: ModelResponse[] } | undefined;
|
||||
setAvailableModels(Array.isArray(inner?.data) ? inner.data : []);
|
||||
} catch {
|
||||
toast.error('Failed to load models');
|
||||
} finally {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user