Lesson

Modify WebSocket Client Events with Mock Service Worker

Modify intercepted WebSocket client messages using Mock Service Worker.

Access
Included
Transcript
Needs source

Listening to the outgoing WebSocket client events is nice, but how about we modify them?

Let's parse the incoming MessageEvent data using JSON.parse, modify it, and provide its stringified version to the chat.broadcast() call to broadcast a different data.

Resources