I am trying to create a voice chat application in React.js. My problem is about sending parameters when users try to join room.
In client side, I run this code to connect server with access token
let accessToken = localStorage.getItem("accessToken")
socket.current = io.connect(process.env.REACT_APP_SOCKET_URL+"/room",{query: { token:accessToken}})
But at first attempt to join room, token is sending as null to server but accessToken variable is not null when I print it to console. Whenever user refreshes the page and tries to join the room again, the token is sending successfully.
Do you have any idea why I am not able to send this variable at first attempt ?