hapi-react-fullstack-boilerplate icon indicating copy to clipboard operation
hapi-react-fullstack-boilerplate copied to clipboard

Uncaught (in promise) TypeError: socket.on is not a function

Open pruhstal opened this issue 7 years ago • 2 comments

Running into the following errors both when hitting https://hapi-react-fullstack-bp.herokuapp.com/chat:

Uncaught (in promise) TypeError: socket.on is not a function

As well as this one:

Uncaught TypeError: socket.emit is not a function

when trying to submit a message in the chat.

I see that you are setting a global variable here:

https://github.com/eseom/hapi-react-fullstack-boilerplate/blob/d15fb9156ba03780117e9bcbea8aafd07c5f3de2/src/client.js#L26

which you reference in Chat.js:

https://github.com/eseom/hapi-react-fullstack-boilerplate/blob/df73f421b3e27b9061ca9933e74f43c94ca84ade/src/containers/Chat/Chat.js#L19, but is it not getting instantiated properly with:

const wsUrl = `ws${window.location.protocol === 'https:' ? 's' : ''}://${window.location.host}`
global.socket = connectNes(store, wsUrl)

?

pruhstal avatar Aug 01 '17 06:08 pruhstal

I'm changing the original code to use hapines instead of socket.io. I was busy and could not pay attention :) I'll try to fix this too. Thank you very much.

eseom avatar Aug 01 '17 09:08 eseom

@eseom ah, good to know :) I come from an Express.js background and have briefly looked at Hapi before, so this is all a bit new to me. Looks like hapines plays more nicely with Hapi, so makes sense to go that route. Thanks for the quick explanation.

pruhstal avatar Aug 01 '17 17:08 pruhstal