Skip to content
This repository was archived by the owner on May 2, 2021. It is now read-only.

Commit c621379

Browse files
committed
update function
1 parent 43cbfa6 commit c621379

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

netlify_functions/deploy-succeeded/deploy-succeeded.js

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,27 @@ exports.handler = async function ({ body = '{}' }) {
4646
if (!eventTitle) {
4747
return response(eventTxt);
4848
}
49-
50-
axios.post(
51-
'https://onesignal.com/api/v1/notifications',
52-
{
53-
included_segments: ['Active Users'],
54-
app_id: ONE_SIGNAL_APP_ID,
55-
headings: {
56-
en: 'Nuovo evento!',
49+
try {
50+
await axios.post(
51+
'https://onesignal.com/api/v1/notifications',
52+
{
53+
included_segments: ['Active Users'],
54+
app_id: ONE_SIGNAL_APP_ID,
55+
headings: {
56+
en: 'Nuovo evento!',
57+
},
58+
contents: {
59+
en: eventTitle,
60+
},
61+
web_url: 'https://www.fevr.it/',
5762
},
58-
contents: {
59-
en: eventTitle,
63+
{
64+
headers: { Authorization: `Basic ${ONE_SIGNAL_API_KEY}` },
6065
},
61-
web_url: 'https://www.fevr.it/',
62-
},
63-
{
64-
headers: { Authorization: `Basic ${ONE_SIGNAL_API_KEY}` },
65-
},
66-
);
67-
return response();
66+
);
67+
} catch (err) {
68+
return response(err.toString());
69+
}
70+
71+
return response('completed!');
6872
};

0 commit comments

Comments
 (0)