From 52a32cfdd1f09da8efed3941012cb253a8d180b4 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sun, 12 Jan 2020 20:06:50 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA=20JSON.parse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/api/reader.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/client/api/reader.js b/client/api/reader.js index 4487119d..0e94c4b1 100644 --- a/client/api/reader.js +++ b/client/api/reader.js @@ -37,7 +37,11 @@ class Reader { //быстрее будет last.split const res = last.split(splitter).pop(); if (res) { - callback(JSON.parse(res)); + try { + callback(JSON.parse(res)); + } catch (e) { + // + } } } }); @@ -46,8 +50,14 @@ class Reader { response = response.data.split(splitter).pop(); if (response) { - response = JSON.parse(response); + try { + response = JSON.parse(response); + } catch (e) { + response = false; + } + } + if (response) { if (response.state == 'finish') {//воркер закончил работу, можно скачивать кешированный на сервере файл callback({step: 4}); const book = await this.loadCachedBook(response.path, callback);