How to enable webhook on user create event?

I am using webhooks and they work well with all the models except user. How to enable it for user model also?
One of the topics on github mentioned that we can modify the user model by adding a function named afterCreate(), but how do i trigger the webhook in afterCreate()?

Or is there an another way to do so?

Well…

var axios = require('axios');
lifecycles: {
async afterCreate(result,data) {
var datatosend = JSON.stringify({
"...": "..."
});
var config = {
method: "post",
url: "https://foo.bar.com/webhook_page",
headers: {
header_1: "..."
},
data: datatosend
};
await axios(config);

This should work for you.

1 Like

Thanks! Yes I did this. It works. I was wondering if there is a webhook trigger function so I could just call it in the user model. Anyway, the issue is solved for now. Thanks again. :slight_smile:

In case someone is acutally looking for a lifecycle hook for user (as I did) checkout this..