0
爲什麼回調中的套接字未定義?套接字在回調中未定義
main.js:26078 Uncaught TypeError: Cannot read property 'on' of undefined
控制檯日誌是一個Socket對象。
var jwt = sessionStorage.token;
console.log(socket);
socket.on('connect', function (socket) { // undefined socket
socket.on('authenticated', function() {
//do other things
})
.emit('authenticate', {token: jwt}); //send the jwt
});
爲什麼這裏的示例在回調中有一個套接字? https://github.com/auth0/socketio-jwt#example-usage –
@amiawizard - 客戶端示例看起來不對。 socket.io客戶機doc不顯示任何參數給'connect'事件的回調。 – jfriend00
@amiawizard - 這是否回答了您的原始問題? – jfriend00