I am currently utilizing the callback function in conjunction with Socket.io as shown below:
loadData(callback) {
var client = new SyncClient(this.socket, this.project);
this.client = client; //From my data function
client.on("connected", () => {
this.values = client.getData();
callback(client);
}
}
However, upon calling my function loadData
, I encountered this console message:
Uncaught TypeError: callback is not a function
.
It seems that the callback()
is referencing its parent which is the function created inside the client.on
instead of the loadData(callback)
. Could this be the issue or is there something else causing this error?
When I call my loadData()
within mounted(), it looks like this:
mounted() {
this.loadData(this.client)
}