( baseId: string, webhookId: string, sdk: AirtableSDK, cursor: number | undefined )
| 420 | } |
| 421 | |
| 422 | async function getPayload( |
| 423 | baseId: string, |
| 424 | webhookId: string, |
| 425 | sdk: AirtableSDK, |
| 426 | cursor: number | undefined |
| 427 | ) { |
| 428 | const url = new URL(`${apiUrl}/${baseId}/webhooks/${webhookId}/payloads`); |
| 429 | if (cursor) { |
| 430 | url.searchParams.append("cursor", cursor.toString()); |
| 431 | } |
| 432 | |
| 433 | const response = await fetch(url.href, { |
| 434 | headers: { |
| 435 | Authorization: `Bearer ${sdk._apiKey}`, |
| 436 | }, |
| 437 | redirect: "follow", |
| 438 | }); |
| 439 | |
| 440 | if (!response.ok) { |
| 441 | throw new Error(`Failed to list webhooks: ${response.statusText}`); |
| 442 | } |
| 443 | |
| 444 | const webhook = await response.json(); |
| 445 | return ListWebhooksResponseSchema.parse(webhook); |
| 446 | } |
| 447 | |
| 448 | async function handleWebhookError(response: Response, errorType: string) { |
| 449 | const rawErrorBody = await response.json(); |
no test coverage detected
searching dependent graphs…