-
Notifications
You must be signed in to change notification settings - Fork 26
/
environment.js
45 lines (36 loc) · 950 Bytes
/
environment.js
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
34
35
36
37
38
39
40
41
42
43
44
45
import Constants from 'expo-constants';
import { Platform } from 'react-native';
const getApiUrl = () => {
const MODE = String(Constants.expoConfig.extra.MODE);
const IOS_LOCAL_URL = String(Constants.expoConfig.extra.IOS_LOCAL_URL);
const ANDROID_LOCAL_URL = String(
Constants.expoConfig.extra.ANDROID_LOCAL_URL
);
const ROCKET_API_URL = String(Constants.expoConfig.extra.ROCKET_API_URL);
const iosDevelop = {
MODE: MODE,
API_URL: IOS_LOCAL_URL,
};
const androidDevelop = {
MODE: MODE,
API_URL: ANDROID_LOCAL_URL,
};
const rocket = {
MODE: MODE,
API_URL: ROCKET_API_URL,
};
if (MODE === 'development') {
if (Platform.OS === 'ios') {
return iosDevelop;
}
return androidDevelop;
}
if (MODE === 'rocket') {
if (!ROCKET_API_URL) {
throw new Error('API_URL is missing.');
}
return rocket;
}
};
console.log(getApiUrl());
export const ENV = getApiUrl();