Pinia store socket.io error
Hi, I want to store my socket.io connection in pinia store. This is my code:
but I am getting this error:
Cannot stringify arbitrary non-POJOs
what to do please?
4 Replies
Nuxt / Pinia stringifies JSON before sending data from the server to the client. It seems like the socket has functions that cannot be strinigified
Making sure this only happens on the client should solve the problem
how can i do that?
i tried rename it to websocket.client.ts but that didnt help
We have a plugin that sets the socket connection and stores it in pinia store, that works. Otherwise you should figure out how to have a pinia store initted only on the client
IDK the exact details but Pinia has great documentation on their website
so should i just use pinia store as a variable and save the connection there in the plugin?
and plugins will always be client side rendered?
I created a client side plugin and it seems to work, it just gives me an error that the socket can be null. Is there a way around it so I don't have to check everywhere that the socket exists?