I am currently working with STRAPI (which is a headless CMS), I need to hit a cloud function whenever an object is created in a collection.
Is there any way to achieve this?
TIA.
You could use lifecycle hooks for that.
// ./src/api/[api-name]/content-types/[api-name]/lifecycles.js
module.exports = {
beforeCreate(event) {
const { data, where, select, populate } = event.params;
// do something
},
afterCreate(event) {
const { result, params } = event;
// do something to the result;
},
};