MCPcopy Index your code
hub / github.com/simstudioai/sim / fetchWebhooks

Function fetchWebhooks

apps/sim/hooks/queries/webhooks.ts:20–41  ·  view source on GitHub ↗
(
  workflowId: string,
  blockId: string,
  signal?: AbortSignal
)

Source from the content-addressed store, hash-verified

18export type { WebhookData }
19
20async function fetchWebhooks(
21 workflowId: string,
22 blockId: string,
23 signal?: AbortSignal
24): Promise<WebhookData | null> {
25 let data: ListWebhooksByBlockResponse
26 try {
27 data = await requestJson(listWebhooksByBlockContract, {
28 query: { workflowId, blockId },
29 signal,
30 })
31 } catch (error) {
32 if (isApiClientError(error) && error.status === 404) return null
33 throw error
34 }
35
36 if (data.webhooks && data.webhooks.length > 0) {
37 return data.webhooks[0].webhook
38 }
39
40 return null
41}
42
43export function useWebhookQuery(workflowId: string, blockId: string, enabled = true) {
44 return useQuery({

Callers 1

useWebhookQueryFunction · 0.85

Calls 2

requestJsonFunction · 0.90
isApiClientErrorFunction · 0.90

Tested by

no test coverage detected