blob: 85dd0f3df52d475d8ffaba4287c9d715ad8d2716 (
plain) (
blame)
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
|
/**
* Get API base URL from store
*/
import {
API_VERSION,
} from '../environment';
import {
LOCAL_SERVER,
SERVER_NOT_LOADED,
} from '../config';
const apiBase = (withVersion = true) => {
let url;
if (!window.ferdi
|| !window.ferdi.stores.settings
|| !window.ferdi.stores.settings.all
|| !window.ferdi.stores.settings.all.app.server) {
// Stores have not yet been loaded - return SERVER_NOT_LOADED to force a retry when stores are loaded
return SERVER_NOT_LOADED;
} if (window.ferdi.stores.settings.all.app.server === LOCAL_SERVER) {
// Use URL for local server
url = `http://127.0.0.1:${window.ferdi.stores.requests.localServerPort}`;
} else {
// Load URL from store
url = window.ferdi.stores.settings.all.app.server;
}
if (withVersion) {
return `${url}/${API_VERSION}`;
}
return url;
};
export default apiBase;
|