From 6cc64372c2e6a691716927e367844585e528aeee Mon Sep 17 00:00:00 2001 From: William Candillon Date: Thu, 16 Nov 2017 20:57:14 +0100 Subject: [PATCH] fix(network): Check for network errors --- src/index.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index d7baed9..7460d6e 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -102,10 +102,14 @@ export class ImageCache { cache.downloading = true; const method = source.method ? source.method : "GET"; cache.task = RNFetchBlob.config({ path }).fetch(method, uri, source.headers); - cache.task.then(() => { - cache.downloading = false; - cache.path = path; - this.notify(uri); + cache.task.then(res => { + if (res.info().status === 200) { + cache.downloading = false; + cache.path = path; + this.notify(uri); + } else { + cache.downloading = false; + } }).catch(() => { cache.downloading = false; // Parts of the image may have been downloaded already, (see https://github.com/wkh237/react-native-fetch-blob/issues/331)