Reduce controller logic scope
This commit is contained in:
19
app/Helpers/Webhook.ts
Normal file
19
app/Helpers/Webhook.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import env from '#start/env'
|
||||
|
||||
export async function sendDataToWebhook(responseData:{ version: number, updatedAt: Date, numberOfRecords: number, data: unknown}) {
|
||||
try {
|
||||
console.log('syncing to webhook')
|
||||
await fetch(env.get('WEBHOOK_URL'),
|
||||
{
|
||||
headers:
|
||||
{
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
method: 'POST',
|
||||
body: JSON.stringify(responseData)
|
||||
}
|
||||
)
|
||||
} catch (e) {
|
||||
console.error('error sending webhook data', e)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user