Hook is not working

System Information
  • Strapi Version: v4.1.3
  • Operating System: Ubuntu 20.04
  • Database: mysql
  • Node Version: v14.19.0
  • NPM Version: 6.14.16
  • Yarn Version: 1.22.5

I have a problem in creating hooks
steps:
1- in ./hook.js
module.exports = {
settings: {
johnTest: {
enabled: true,
debug: true
},

},
};

2- in ./hooks/johnTest/index.js i made console.log(“John”);
but it does not appear

module.exports = strapi => {
const hook = {
/**
* Default options
*/
defaults: {
// config object
},

  /**
   * Initialize the hook
   */
  async initialize() {
    // Merge defaults and config/hook.json
    const settings = {...this.defaults, ...strapi.config.hook.settings.**};

console.log(“John”);
// await someAsyncCode()
},
};

return hook;

};

Blockquote

notice that i followed all steps in Different types/categories of Strapi Hooks

can any one help me to know what is missing?


1 Like

Hi,

I have a similar problem. Did you get it resolved?

Anyone know how to solve this? I have a similar problem.