From d12fc4acb306df2bca582638d542dc64737edadb Mon Sep 17 00:00:00 2001 From: AndreyNikitin Date: Tue, 14 Dec 2021 11:46:11 +0300 Subject: [PATCH] Fetch tool get (#2) * fix(fetchtool): catch fetch exception on get resource * fix(fetchtool): update another fetch --- src/FetchWorkerTool.worker.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/FetchWorkerTool.worker.js b/src/FetchWorkerTool.worker.js index 43965250..be87df0d 100644 --- a/src/FetchWorkerTool.worker.js +++ b/src/FetchWorkerTool.worker.js @@ -49,7 +49,10 @@ const onMessage = ({data: job}) => { jobsActive++; fetch(job.url, job.options) - .then(response => response.arrayBuffer()) + .then(result => { + if (result.ok) return result.arrayBuffer(); + return Promise.reject(result.status); + }) .then(buffer => complete.push({id: job.id, buffer})) .catch(error => complete.push({id: job.id, error})) .then(() => jobsActive--);