How can I call an async function in another controller? 🤔

Hello @mingxi ,

For this use case I would say that it depends on what the filterObject(obj) function is doing. If its content is strongly related to the business context you are within (API, plugin, …), I would recommend to expose it has part of a of service. So you can call it from anywhere using thee proper syntax.

On the other part, if the business logic of the function is not bound to your context. I would export it has a function in the config/functions directory.

I don’t know if this is the recommended way for handling this, but it works for me.

Hope that helps.

2 Likes