0

Based off this question, I have written the following lifecycle function in my in my api/foo/model/foo.js file.

'use strict';

module.exports = {
  async afterUpdate(modifications, filter, resultData) {
    strapi.log.error('here');
    console.log('there');
  }
}

However, when I update a Foo in the Strapi admin console, nothing is logged. What am I missing?

Mathew Alden
  • 1,458
  • 2
  • 15
  • 34
  • I think thats Strapi 3 way of writing hooks, check out https://docs.strapi.io/developer-docs/latest/development/backend-customization/models.html#declarative-and-programmatic-usage....even though I am following current docs, its not trigerring for me. – Chirdeep Tomar Jan 19 '22 at 23:32
  • Open issue on github: https://github.com/strapi/strapi/issues/11828 – Chirdeep Tomar Jan 19 '22 at 23:38

1 Answers1

0

I'm using Strapi 3, not Strapi 4.

The correct way to write the above code in Strapi 3 is

'use strict';

module.exports = {
  lifecycles: {
    async afterUpdate(event) {
      strapi.log.error('here');
      console.log('there');
    }
  }
}

And then, of course, you can remove the console.log statement because strapi.log works just fine.

Mathew Alden
  • 1,458
  • 2
  • 15
  • 34