Skip to content

Commit 54490c7

Browse files
authored
Add path generated id
1 parent 0cc5ee5 commit 54490c7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

functions/submission-created.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const sanityClient = require('@sanity/client')
2+
const { uuid } = require('@sanity/uuid')
23
const client = sanityClient({
34
projectId: 'zv292tg5',
45
dataset: 'production',
@@ -7,7 +8,9 @@ const client = sanityClient({
78

89
exports.handler = async function (event, context, callback) {
910
const { payload } = JSON.parse(event.body)
10-
const result = await client.create({ _type: 'submission.form', ...payload })
11+
const result = await client.create({
12+
_id: `submission.${uuid()}`
13+
_type: 'submission.form', ...payload })
1114
callback(null, {
1215
statusCode: 200
1316
})

0 commit comments

Comments
 (0)