Skip to content
Advertisement

Using a module.export function inside the same file same file where it’s implemented

I have a controller with two functions:

module.exports.getQuestionnaire = function(application, req, res) {
}

module.exports.getClientDetails = function(application, req, res) {
}

I want to call the getQuestionnaire function inside the getClientDetails function.

Just calling getQuestionnaire() does not work. How should I do this?

Advertisement

Answer

What I usually do:

const getQuestionnaire = () => {
  //getClientDetails()
}
    
const getClientDetails = () => {
  //getQuestionnaire()
}
    
module.exports = {getQuestionnaire, getClientDetails}
Advertisement