How to get file that is calling function

Viewed 29

I have this global function in my main app file

  async getTip(){
    const tipschema = require('./schemas/tipschema')
    const tipschemas = await tipschema.find()
        const randomschema = tipschemas[Math.floor(Math.random()*tipschemas.length)]
        const randomtip = randomschema.tip
        return randomtip
  },

Is there any way I can get the file name that is calling the function? For example:

  async getTip(){
const file = await req.file // example of what I'm trying to do
  },

thanks

1 Answers
Related