Abort web socket requests when no token is present

This commit is contained in:
Jannis Mattheis 2018-03-18 14:01:47 +01:00 committed by Jannis Mattheis
parent 090142c281
commit 1e33fd0ea4
1 changed files with 4 additions and 0 deletions

View File

@ -35,6 +35,10 @@ export function deleteMessage(id) {
* Starts listening to the stream for new messages. * Starts listening to the stream for new messages.
*/ */
export function listenToWebSocket() { export function listenToWebSocket() {
if (!getToken()) {
return;
}
const ws = new WebSocket('ws://localhost:80/stream?token=' + getToken()); const ws = new WebSocket('ws://localhost:80/stream?token=' + getToken());
ws.onerror = (e) => { ws.onerror = (e) => {