aboutsummaryrefslogtreecommitdiff
path: root/src/services/CommonService.ts
diff options
context:
space:
mode:
authorIvan Chen <ivan@thetaggid.com>2021-01-27 19:32:21 -0500
committerGitHub <noreply@github.com>2021-01-27 19:32:21 -0500
commit19d2a861f260c02031d951f3d43bff8ac672146d (patch)
tree253abceb267dfb75ac9118995886ff152c1ba74b /src/services/CommonService.ts
parent60d3d97ad6913369762877a9dbfdaac0473deb28 (diff)
parentdc9556867dd44b706c43678d40802a335ff40658 (diff)
Merge pull request #203 from IvanIFChen/tma577-profile-slowness
[TMA-577] Profile Slowness
Diffstat (limited to 'src/services/CommonService.ts')
-rw-r--r--src/services/CommonService.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/services/CommonService.ts b/src/services/CommonService.ts
new file mode 100644
index 00000000..4f9fb47a
--- /dev/null
+++ b/src/services/CommonService.ts
@@ -0,0 +1,22 @@
+import RNFetchBlob from 'rn-fetch-blob';
+
+export const loadImageFromURL = async (url: string) => {
+ try {
+ if (!url) {
+ return undefined;
+ }
+ const response = await RNFetchBlob.config({
+ fileCache: true,
+ appendExt: 'jpg',
+ }).fetch('GET', url);
+ const status = response.info().status;
+ if (status === 200) {
+ return response.path();
+ } else {
+ return undefined;
+ }
+ } catch (error) {
+ console.log(error);
+ return undefined;
+ }
+};