Skip to content

Commit f9b0ef5

Browse files
committed
fix: correctly preserve id
1 parent c03d807 commit f9b0ef5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/nuxt/src/runtime/payload-plugin.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,18 @@ export default definePayloadPlugin(() => {
3737
typeof data === 'object' &&
3838
'id' in data &&
3939
JSON.stringify({
40-
id: data.id,
4140
...data,
41+
id: data.id,
4242
})
4343
)
4444
definePayloadReviver('DocumentData', (data: string) => {
4545
const parsed = JSON.parse(data)
4646
// preserve the non-enumerable property
4747
// we need to delete it first
48+
const idValue = parsed.id
4849
delete parsed.id
4950
return Object.defineProperty(parsed, 'id', {
50-
value: parsed.id,
51+
value: idValue,
5152
})
5253
})
5354
})

0 commit comments

Comments
 (0)