Skip to content

Uncaught ReferenceError: io is not defined #9

@adopudi

Description

@adopudi

I have modified my hackathon-starter site according to the Readme file.
After running npm start and accessing the site from a client I get the following error:

Uncaught ReferenceError: io is not defined

The error is generated by the following client code:

$(document).ready(function () {
  // init socket.io
  const socket = io.connect(window.location.hostname + ':3001')
  socket.on('greet', (data) => {
    console.log(data)
    socket.emit('respond', { message: 'Hey there, server!' })
  })
})

While in the hackaton-starter code there is the following line in layout.pug :

script(src='/socket.io/socket.io.js')

I don't see the same in this repo, and if try to add it it gives another error since there is no socket.io library compiled by laravel-mix .

How is socket.io supposed to be loaded in the client side? am I missing something obvious?

Thank you in advance

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