diff --git a/jetstream.ts b/jetstream.ts index feba7b8..6731760 100644 --- a/jetstream.ts +++ b/jetstream.ts @@ -24,16 +24,17 @@ const fireWebhooks = async ( const webhooks = getWebhooksByDid(did); if (webhooks.length === 0) return; const results = await Promise.allSettled( - webhooks.map(({ method, url, token }) => - fetch(url, { + webhooks.map(({ method, url, token }) => { + const hasBody = method !== "GET" && method !== "HEAD"; + return fetch(url, { method, headers: { - "Content-Type": "application/json", + ...(hasBody ? { "Content-Type": "application/json" } : {}), ...(token ? { Authorization: `Bearer ${token}` } : {}), }, - body: JSON.stringify(payload), - }) - ), + body: hasBody ? JSON.stringify(payload) : undefined, + }); + }), ); for (const result of results) { if (result.status === "rejected") {