hapi-react-fullstack-boilerplate
hapi-react-fullstack-boilerplate copied to clipboard
Uncaught (in promise) TypeError: socket.on is not a function
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)
?
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 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.