I'm using Socket.io's callback function, like this:
loadData(callback) { var client = new SyncClient(this.socket, this.project); this.client = client; //Data function from me client.on("connected", () => { this.values = client.getData(); callback(client); } }
But when I call my function loadData
, this error message appears in the console: Uncaught TypeError: callback is not a function
.
I think callback()
is trying to call it's parent which is a function created inside client.on
instead of loadData( callback)
? Or does the problem lie elsewhere?
Call my loadData()
like this in my mounted
:
mounted() { this.loadData(this.client) }
Try using the data (res) received from the
.find
callback function and pass it to your callback function: