diff options
author | Joffrey Bion <joffrey.bion@amadeus.com> | 2017-07-18 19:01:06 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@amadeus.com> | 2017-07-18 19:01:06 +0200 |
commit | 4a1827b5619da5f5e877263d06f108cae558f1cb (patch) | |
tree | 1a360ef0a2fc1945917b006a676127b5690084e1 /frontend/src/utils | |
parent | Update gradle wrapper to 4.0.1 (diff) | |
download | seven-wonders-4a1827b5619da5f5e877263d06f108cae558f1cb.tar.gz seven-wonders-4a1827b5619da5f5e877263d06f108cae558f1cb.tar.bz2 seven-wonders-4a1827b5619da5f5e877263d06f108cae558f1cb.zip |
Fix handler for empty websocket messages
Diffstat (limited to 'frontend/src/utils')
-rw-r--r-- | frontend/src/utils/websocket.js | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/frontend/src/utils/websocket.js b/frontend/src/utils/websocket.js index b01531cf..6acd0806 100644 --- a/frontend/src/utils/websocket.js +++ b/frontend/src/utils/websocket.js @@ -41,7 +41,9 @@ export const createWsConnection = (headers: Object = {}): Promise<SocketObjectTy export const createSubscriptionChannel = (socket: SocketType, path: string) => { return eventChannel((emitter: (data: any) => void) => { const socketSubscription: SocketSubscriptionType = socket.subscribe(path, (event: SocketEventType) => { - emitter(JSON.parse(event.body)); + // not all events have a body + const value = event.body && JSON.parse(event.body); + emitter(value); }); return () => socketSubscription.unsubscribe(); }); |