blob: 9fa7417f29d1c3db32ae90bec30e345f8685b988 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import RNFetchBlob from 'rn-fetch-blob';
import {VERSION_ENDPOINT} from '../constants';
export const loadImageFromURL = async (url: string) => {
try {
if (!url) {
return undefined;
}
const response = await RNFetchBlob.config({
fileCache: false,
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;
}
};
export const getLiveVersion = async () => {
try {
const response = await fetch(VERSION_ENDPOINT, {method: 'GET'});
return response.status === 200 ? await response.json() : undefined;
} catch (error) {
console.log(error);
return undefined;
}
};
|