Custom helper functions


I read that I could put utility functions under config/functions

for example config/functions/utilities.js
module.exports = {
async test() {
return 0;
and then call them
let myVar = await strapi.config.functions[‘utilities’].test()

It hangs hower for me (strapi 4)

What am I doing wrong?

1 Like

I am also having similar issue, did you have any progress on this?

I did solve it

under the config folder I created a functions folder and you create a js file named for what you are doing:
eg myfunction.js

inside this file

module.exports = {
  async func1(input1, input2) {
    // do your work here

Now the part that made it work was I had to import it in my controllers or where ever you want to use it

ie const {func1} = require("…/…/…/…/config/functions/myfunction");

Hope it help

1 Like

thanks it also worked for me :slight_smile: