diff --git a/docs/api/websockets.md b/docs/api/websockets.md index 4e55b8761b..7722d731a2 100644 --- a/docs/api/websockets.md +++ b/docs/api/websockets.md @@ -192,7 +192,7 @@ const server = Bun.serve<{ username: string }>({ close(ws) { const msg = `${ws.data.username} has left the chat`; ws.unsubscribe("the-group-chat"); - ws.publish("the-group-chat", msg); + server.publish("the-group-chat", msg); }, }, }); diff --git a/docs/guides/websocket/pubsub.md b/docs/guides/websocket/pubsub.md index 7403d4d2f5..ff3a31fdf1 100644 --- a/docs/guides/websocket/pubsub.md +++ b/docs/guides/websocket/pubsub.md @@ -28,7 +28,7 @@ const server = Bun.serve<{ username: string }>({ }, close(ws) { const msg = `${ws.data.username} has left the chat`; - ws.publish("the-group-chat", msg); + server.publish("the-group-chat", msg); ws.unsubscribe("the-group-chat"); }, },