eseom / hapi-react-fullstack-boilerplate

Hapi, Sequelize, React, etc.
MIT License
21 stars 4 forks source link

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

Open pruhstal opened 7 years ago

pruhstal commented 7 years ago

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)

?

eseom commented 7 years ago

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.

pruhstal commented 7 years ago

@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.