diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-06-22 18:07:06 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-06-22 18:07:06 +0200 |
| commit | 9359758ce631528ae2b0deb82df05f908d5c42a2 (patch) | |
| tree | b6a43b59ca22c8bd0acf79e7a4b3f1beb20470eb /app/client/socket/socket.task.js | |
| parent | 3347e241b860001721cb8c07fc6a82b51f97335e (diff) | |
why is this double encoded
Diffstat (limited to 'app/client/socket/socket.task.js')
| -rw-r--r-- | app/client/socket/socket.task.js | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/app/client/socket/socket.task.js b/app/client/socket/socket.task.js index 77f1310..1b33cd9 100644 --- a/app/client/socket/socket.task.js +++ b/app/client/socket/socket.task.js @@ -5,9 +5,23 @@ import { socket } from './socket.connection' let finishTimeout; -socket.on('task_res', (data) => { +socket.on('task_res', (raw_data) => { // does not like the nested task object for some reason.. - data = JSON.parse(data) + console.log(typeof raw_data) + let data; + try { + if (typeof raw_data === 'string') { + data = JSON.parse(raw_data) + if (typeof data === 'string') { + data = JSON.parse(data) + } + } else { + data = raw_data + } + } catch (e) { + console.warn('problem with json', e) + return + } if (data.task) { dispatch({ type: types.task.update, data: data.task }) } |
