Skip to content

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

@pruhstal

Description

@pruhstal

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:

global.socket = connectNes(store, wsUrl)

which you reference in Chat.js:

, but is it not getting instantiated properly with:

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

?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions