From cfbea6bbbaf3e338d40ea1e3b30f0d616fa69ff6 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Fri, 18 Mar 2022 14:31:11 +0100 Subject: [PATCH] =?UTF-8?q?fix(api):=20=F0=9F=90=9B=20subscribeWebhook=20u?= =?UTF-8?q?psert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../blocks/[blockId]/steps/[stepId]/subscribeWebhook.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/viewer/pages/api/typebots/[typebotId]/blocks/[blockId]/steps/[stepId]/subscribeWebhook.ts b/apps/viewer/pages/api/typebots/[typebotId]/blocks/[blockId]/steps/[stepId]/subscribeWebhook.ts index 9a96184f6..f66a92752 100644 --- a/apps/viewer/pages/api/typebots/[typebotId]/blocks/[blockId]/steps/[stepId]/subscribeWebhook.ts +++ b/apps/viewer/pages/api/typebots/[typebotId]/blocks/[blockId]/steps/[stepId]/subscribeWebhook.ts @@ -24,9 +24,10 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { const { webhookId } = typebot.blocks .find(byId(blockId)) ?.steps.find(byId(stepId)) as WebhookStep - await prisma.webhook.update({ + await prisma.webhook.upsert({ where: { id: webhookId }, - data: { url, body: '{{state}}', method: 'POST' }, + update: { url, body: '{{state}}', method: 'POST' }, + create: { url, body: '{{state}}', method: 'POST', typebotId }, }) return res.send({ message: 'success' })