Reputation: 70416
I added socket.io-client.js to my front end application. Because backend is driven by sails.js I added a socket.io wrapper provided by sails:
https://raw.githubusercontent.com/balderdashy/sails.io.js/master/sails.io.js
When I refresh site I get an error in this line:
Socket.prototype.get = function(url, data, cb)
Console:
Uncaught TypeError: Cannot read property 'prototype' of undefined sails.io.js:311 SailsIOClient sails.io.js:311 (anonymous function) sails.io.js:724 (anonymous function) sails.io.js:726
Is this some bug in the sails.io.js script? I am not using the script right now, just included it.
Upvotes: 0
Views: 2250
Reputation: 17072
I managed to have it working using the version 0.9.17 of socket.io-client
Upvotes: 0
Reputation: 24948
The version of sails.io.js
in that repo is under active development. To safely implement socket.io
in your Sails project, you can use the sails.io.js
that is provided with new Sails projects created by the sails new
command.
That having been said, the issue here is that you need to include the dist version of the repo's sails.io.js
file, which includes the code for the socket.io
client inline. So don't include a separate copy of socket.io.js
in your project if you go that route. The new sails.io.js
has a few key benefits:
response
argument to request callbacks with the response status, headers, etc.sails.io.js
and respond accordinglyAgain, it's under development so read the doc page carefully and use at your own risk!
Upvotes: 1