Reputation: 9191
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
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)
}
}
}
Upvotes: 11
Views: 31255
Reputation: 9191
The issue was that it wasn't being instantiated.
Use
export default new MenuRepository()
Instead of
export default MenuRepository
Upvotes: 3