mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 08:19:07 +00:00
feat(webhook): use strapi fetch in webhooks
This commit is contained in:
parent
e696b13c34
commit
50a2e58dda
@ -395,6 +395,7 @@ class Strapi {
|
||||
eventHub: this.eventHub,
|
||||
logger: this.log,
|
||||
configuration: this.config.get('server.webhooks', {}),
|
||||
fetch: this.fetch,
|
||||
});
|
||||
|
||||
this.registerInternalHooks();
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
const debug = require('debug')('strapi:webhook');
|
||||
const _ = require('lodash');
|
||||
const fetch = require('node-fetch');
|
||||
|
||||
const WorkerQueue = require('./worker-queue');
|
||||
|
||||
@ -15,12 +14,13 @@ const defaultConfiguration = {
|
||||
};
|
||||
|
||||
class WebhookRunner {
|
||||
constructor({ eventHub, logger, configuration = {} }) {
|
||||
debug('Initialized webhook runer');
|
||||
constructor({ eventHub, logger, configuration = {}, fetch }) {
|
||||
debug('Initialized webhook runner');
|
||||
this.eventHub = eventHub;
|
||||
this.logger = logger;
|
||||
this.webhooksMap = new Map();
|
||||
this.listeners = new Map();
|
||||
this.fetch = fetch;
|
||||
|
||||
if (typeof configuration !== 'object') {
|
||||
throw new Error(
|
||||
@ -76,7 +76,7 @@ class WebhookRunner {
|
||||
run(webhook, event, info = {}) {
|
||||
const { url, headers } = webhook;
|
||||
|
||||
return fetch(url, {
|
||||
return this.fetch(url, {
|
||||
method: 'post',
|
||||
body: JSON.stringify({
|
||||
event,
|
||||
|
Loading…
x
Reference in New Issue
Block a user