I'm writing a client that communicates with a websocket server. Currently, the socket server sends a generated "token" to the client, which then sets it in storage with:
localStorage.setItem('token', json.token);
And redirects to the next page, which on load, runs this code:
token = localStorage.getItem('token')
console.log(token)
socket.send(JSON.stringify({"type": "getplayerinfo", "token": token}));
When doing console.log(token), I get the token. However, when sending the token through the socket, I get:
Uncaught DOMException: An attempt was made to use an object that is not, or is no longer, usable
I've been debugging this for 3 days and have wracked my brain. Any tips?