-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
additional data on trigger event #14
Comments
You can't do this: webHooks.trigger(shortName, payloadData, additionalData); The third parameter is reserved for the Example: webHooks.trigger(shortName, {myData: 'hello', moreData: 'even more data'});
emitter.on('*.success', (shortname, statusCode, body)=> {
var myData = body.myData
var moreData = body.moreData
// ...
}); |
hello thanks for the answer but in the body parameter i received the request response of the url configured in the shorname. |
Ok, I was supposing that the web-server "mirrors" your body request. |
did the above but the body contains the response body, any help to track what have been sent from my side as in the request body, thank you |
this how i am triggering the webhook : // dispatch the webhook :
await webHooks.trigger('OrderCreated', {data: data}, {Authorization: Authorization});
and here is the function I am using to log all the webhooks dispatched : emitter.on('*.failure', async function (shortname, statusCode, body) {
let TIMESTAMP = new Date().toLocaleString("en-US", {timeZone: "Asia/Riyadh"});
let DATE = new Date().toLocaleDateString("en-US", {timeZone: "Asia/Riyadh"}).replace("/","-").replace("/","-").substring(0,9);
console.log(colors.error('ERROR on trigger webhook ' + shortname + ' with status code', statusCode, 'and body', body , 'At : ',TIMESTAMP))
let obj = {
shortname,
statusCode,
TIMESTAMP,
body,
}
// console.log({obj})
await (async () => {
let event = []
event.push({} = obj)
const csv = new ObjectsToCsv(event);
// Save to file:
await csv.toDisk(`./logs/FAILED-WEBHOOKS-${DATE}-${shortname}.csv`, { append: true });
// Return the CSV file as string:
// console.log(await csv.toString());
})();
}) anyway to track the body of the request I am dispatching, the data object, thanks again |
it's up to your app logic to keep track of what you're dispatching. |
hello i need to send a additional data on trigger event for use it after on succes event, for example:
thanks
The text was updated successfully, but these errors were encountered: