mirror of
https://github.com/plankanban/planka.git
synced 2025-08-08 15:05:30 +02:00
fix: webhooks fetch wrapped into try catch
This commit is contained in:
parent
72896a66b3
commit
880a27770b
1 changed files with 14 additions and 8 deletions
|
@ -116,17 +116,23 @@ async function sendWebhook(webhook, event, data, user) {
|
|||
user: sails.helpers.utils.jsonifyRecord(user),
|
||||
});
|
||||
|
||||
const response = await fetch(webhook.url, {
|
||||
headers,
|
||||
body,
|
||||
method: 'POST',
|
||||
});
|
||||
try {
|
||||
const response = await fetch(webhook.url, {
|
||||
headers,
|
||||
body,
|
||||
method: 'POST',
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const message = await response.text();
|
||||
if (!response.ok) {
|
||||
const message = await response.text();
|
||||
|
||||
sails.log.error(
|
||||
`Webhook ${webhook.url} failed with status ${response.status} and message: ${message}`,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
sails.log.error(
|
||||
`Webhook ${webhook.url} failed with status ${response.status} and message: ${message}`,
|
||||
`Webhook ${webhook.url} failed with error message: ${e.message}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue