Skip to content
Advertisement

Cannot call a function inside mounted()

I have a chat API that I’m connecting to a Vue.js project.

When user goes to a chat room page, it sends an ajax request and then calls the function that fetches the whole chat history:

JavaScript

but it fails with:

TypeError: _this.fetchChatSessionHistory is not a function

I understand that it might be defined at a wrong place but I have no idea how do it right.

Advertisement

Answer

You should put that function inside methods property as follows :

JavaScript
Advertisement