Skip to content

Commit 3cfd633

Browse files
committed
feat: enhance data handling in ObjectDataTable and simulateBrowser for improved response structure
1 parent e01c6b8 commit 3cfd633

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

examples/app-react-crud/src/components/ObjectDataTable.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,15 @@ export function ObjectDataTable({ client, objectApiName, onEdit }: ObjectDataTab
5252
setRecords(result.value);
5353
// If count is supported
5454
if (typeof result.count === 'number') setTotal(result.count);
55+
} else if (result && result.success && Array.isArray(result.data)) {
56+
// Handle Standard Envelope { success: true, data: [], meta: { count } }
57+
setRecords(result.data);
58+
if (result.meta && typeof result.meta.count === 'number') setTotal(result.meta.count);
5559
} else if (Array.isArray(result)) {
5660
setRecords(result); // Fallback for simulation that might just return array
61+
} else if (result && typeof result === 'object' && result?.data && Array.isArray(result.data)) {
62+
/* Fallback for partial envelope */
63+
setRecords(result.data);
5764
}
5865
}
5966
} catch (err) {

examples/app-react-crud/src/mocks/simulateBrowser.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,12 @@ export async function simulateBrowser() {
6464
filters: filters
6565
});
6666

67-
// Return Buffer/JSON
68-
return HttpResponse.json({ value: result.data, count: result.count });
67+
// Return Standard Envelope to match packages/runtime/src/http-dispatcher.ts
68+
return HttpResponse.json({
69+
success: true,
70+
data: result.data,
71+
meta: { count: result.count }
72+
});
6973
} catch (err: any) {
7074
return HttpResponse.json({ error: err.message }, { status: 500 });
7175
}

0 commit comments

Comments
 (0)