Webpack Imported Module is not a function

Total
16
Shares

I have a repository (in a MenuRepository.js file) that has an index() method, when I try to call that method from my mounted() function in my Vue instance, I get the following error

enter image description here

This has been working before, So I can’t imagine what happened..
This is the code of my Vue instance.

class MenuRepository {
  async index () {
    const result = await Nova.request().get('/')
    return result.data
  }
}

export default MenuRepository

And this is the Vue file

import MenuRepository from '../repositories/MenuRepository'

export default {
  async mounted () {
    try {
      const menus = await MenuRepository.index()
    } catch (err) {
      console.error(err)
    }
  }
}

Solution

Solution

The issue was that it wasn’t being instantiated.

Use

export default new MenuRepository()

Instead of

export default MenuRepository
Leave a Reply

Your email address will not be published. Required fields are marked *