Hi , Iam trying to add comments section in my web app , using phoenix.
The below method works fine.
socket.connect()
let channel = socket.channel(`comments:1`, {})
channel.join()
.receive("ok", resp => { console.log("Joined successfully", resp) })
.receive("error", resp => { console.log("Unable to join", resp) })
export default socket;
it gives me a joined succesfuly response in my console.but when i make the function like this…
socket.connect()
const createSocket = (topicId) => {
let channel = socket.channel(`comments:%{topicId}`, {})
channel.join()
.receive("ok", resp => { console.log("Joined successfully", resp) })
.receive("error", resp => { console.log("Unable to join", resp) })
}
window.createSocket=createSocket;
and i called in html file…
<script>
window.createSocket(<%= @topic.id %>)
</script>
while compiling I got an error that websocket disconnected while handshaking…