aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/apiBase.js
diff options
context:
space:
mode:
authorLibravatar vantezzen <properly@protonmail.com>2019-08-25 13:56:14 +0200
committerLibravatar vantezzen <properly@protonmail.com>2019-08-25 13:56:14 +0200
commit051314eac6f062f18ea52a2fda2f1ecd1164b64b (patch)
tree067f432695184ae78ed2474723e9b0ec70d42507 /src/api/apiBase.js
parentAdd custom tray icons (diff)
downloadferdium-app-051314eac6f062f18ea52a2fda2f1ecd1164b64b.tar.gz
ferdium-app-051314eac6f062f18ea52a2fda2f1ecd1164b64b.tar.zst
ferdium-app-051314eac6f062f18ea52a2fda2f1ecd1164b64b.zip
Unifying apiBase function
Diffstat (limited to 'src/api/apiBase.js')
-rw-r--r--src/api/apiBase.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/api/apiBase.js b/src/api/apiBase.js
new file mode 100644
index 000000000..42f09eaa8
--- /dev/null
+++ b/src/api/apiBase.js
@@ -0,0 +1,25 @@
1/**
2 * Get API base URL from store
3 */
4import {
5 API_VERSION,
6 API,
7} from '../environment';
8
9const apiBase = () => {
10 let url;
11 if (!window.ferdi.stores.settings || !window.ferdi.stores.settings.all) {
12 // Stores have not yet been loaded - send invalid URL to force a retry when stores are loaded
13 url = 'https://localhost:9999';
14 } else if (window.ferdi.stores.settings.all.app.server) {
15 // Load URL from store
16 url = window.ferdi.stores.settings.all.app.server;
17 } else {
18 // Use default server url
19 url = API;
20 }
21
22 return `${url}/${API_VERSION}`;
23};
24
25export default apiBase;