From b3a5f5cbc343ffdd654de70262847220e9533adc Mon Sep 17 00:00:00 2001 From: jbion Date: Fri, 22 Feb 2019 21:26:19 +0100 Subject: Fix websocket value when no message body is received --- frontend/src/api/websocket.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'frontend/src') diff --git a/frontend/src/api/websocket.js b/frontend/src/api/websocket.js index 6813676c..2fc045ff 100644 --- a/frontend/src/api/websocket.js +++ b/frontend/src/api/websocket.js @@ -7,7 +7,7 @@ const DEFAULT_DEBUG_OPTIONS = { debug: process.env.NODE_ENV !== 'production', }; -export type Callback = (value?: T) => void; +export type Callback = (value: T) => void; export type UnsubscribeFn = () => void; export type SubscribeFn = (callback: Callback) => UnsubscribeFn; @@ -28,7 +28,7 @@ export class JsonStompClient { const socketSubscription: Subscription = this.client.subscribe(path, (message: Message) => { // not all frames have a JSON body const value: T | void = message && JsonStompClient.parseBody(message); - callback(value); + callback(value || {}); }); return () => socketSubscription.unsubscribe(); } -- cgit