A
A
alaskafx2021-08-20 13:40:54
Socket.io
alaskafx, 2021-08-20 13:40:54

TypeError: Object(...) is not a function - how to solve?

socket.js file:

import { io } from "socket.io-client";

const URL = "http://localhost:3001";
const socket = io(URL, { autoConnect: false });

socket.onAny((event, ...args) => {
  console.log(event, args);
});

export default socket;


import socket from "./socket.js";

methods: {
onUsernameSelection(username){
  this.usernameArleadySelected = true;
  socket.auth = {username}
  socket.connect()
} 
  },


Well, immediately an error occurs after import: TypeError: Object(...) is not a function

How to solve?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question