'Getting errors while trying to log inputs from a form

const socket = io('https://localhost:3000')
const messageForm = document.getElementById('send-container')
const messageInput = document.getElementById('message-input')

socket.on('chat-message', data =>{
console.log(data)

}
)

messageForm.addEventListener('submit', e => {
e.preventDefault()
const message = messageInput.value
socket.emit('send-chat-message', message)
messageInput.value = ''
})

    <script defer src="http://localhost:3000/socket.io/socket.io.js"></script>
<script defer src="chatscript.js"></script>

<div id="message-container"></div>
    <form id='send-container'>
        <input type="text" id="message-input"></input>
        <button type="submit" id="send-button">send</button>
    </form>

When a user enters a submits a message in the input tag, the message should be logged into the console. But instead, i'm getting

Loading failed for the <script> with source “http://localhost:3000/socket.io/socket.io.js”.
 file:///C:/Users/myname/Desktop/AvackGames/AvackGames/chatscript.js:1

Errors on Firefox and errors on Chrome.

GET http://localhost:3000/socket.io/socket.io.js net::ERR_CONNECTION_REFUSED avackchat.html:9
chatscript.js:1 Uncaught ReferenceError: io is not defined
    at chatscript.js:1:16

I've tried running "npm install cors" but it hasn't fixed the issue.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source