Life cycle hook >> afterPublish

Hi all,
I’m trying to get data after Publish the content.
I found the way how to get Publish event which is by using beforeUpdate life cycle hook.
But when I use beforeUpdate, there is no data return that I want to get.
I don’t want to disable publish/draft setting. So how can I do for that?
If some one knows, could you please tell me how can I get the data after Publish?

1 Like

You can listen to afterUpdate hook and check publishedAt field.
If it is not null it means the content is published.

You can get the current data in database as well and see if new data is published and previous publisehdAt is null you know that the content is published in this very update!
(it might be publish->unpulish-publish again etc) every time you have publish from unpublish will notify

PS: This is the workaround that I use and works great. It could be nice if strapi supports out of the box just a afterPublish event as well