aboutsummaryrefslogtreecommitdiff
path: root/src/services/CommonService.ts
blob: 4f9fb47a3e49ebe86f1a31e12adf2b7b22c40347 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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;
  }
};