mirror of
https://github.com/mendableai/firecrawl.git
synced 2024-11-16 19:58:08 +08:00
Update webhook.ts
This commit is contained in:
parent
1a16378fe8
commit
beb7526d1d
|
@ -7,13 +7,16 @@ export const callWebhook = async (teamId: string, data: any) => {
|
|||
|
||||
if (!selfHostedUrl) {
|
||||
const { data: webhooksData, error } = await supabase_service
|
||||
.from('webhooks')
|
||||
.select('url')
|
||||
.eq('team_id', teamId)
|
||||
.from("webhooks")
|
||||
.select("url")
|
||||
.eq("team_id", teamId)
|
||||
.limit(1);
|
||||
|
||||
if (error) {
|
||||
console.error(`Error fetching webhook URL for team ID: ${teamId}`, error.message);
|
||||
console.error(
|
||||
`Error fetching webhook URL for team ID: ${teamId}`,
|
||||
error.message
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -22,7 +25,7 @@ export const callWebhook = async (teamId: string, data: any) => {
|
|||
}
|
||||
|
||||
webhookUrl = webhooksData[0].url;
|
||||
}
|
||||
}
|
||||
|
||||
let dataToSend = [];
|
||||
if (data.result.links && data.result.links.length !== 0) {
|
||||
|
@ -36,19 +39,20 @@ export const callWebhook = async (teamId: string, data: any) => {
|
|||
}
|
||||
|
||||
await fetch(webhookUrl, {
|
||||
method: 'POST',
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
success: data.success,
|
||||
project_id: data.project_id,
|
||||
data: dataToSend,
|
||||
error: data.error || undefined,
|
||||
}),
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`Error sending webhook for team ID: ${teamId}`, error.message);
|
||||
console.error(
|
||||
`Error sending webhook for team ID: ${teamId}`,
|
||||
error.message
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user