summaryrefslogtreecommitdiff
path: root/src/misc
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc')
-rw-r--r--src/misc/request-helper.js17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/misc/request-helper.js b/src/misc/request-helper.js
index 7cc17bf..317dada 100644
--- a/src/misc/request-helper.js
+++ b/src/misc/request-helper.js
@@ -1,15 +1,7 @@
-import { store } from '../store/configureStore';
-import { getClashAPIConfig } from 'd/app';
-
const headersCommon = {
'Content-Type': 'application/json'
};
-export function getAPIConfig() {
- // this is cheating...
- return getClashAPIConfig(store.getState());
-}
-
export function genCommonHeaders({ secret }) {
const h = { ...headersCommon };
if (secret) {
@@ -21,3 +13,12 @@ export function genCommonHeaders({ secret }) {
export function getAPIBaseURL({ hostname, port }) {
return `http://${hostname}:${port}`;
}
+
+export function getURLAndInit({ hostname, port, secret }) {
+ const baseURL = getAPIBaseURL({ hostname, port });
+ const headers = genCommonHeaders({ secret });
+ return {
+ url: baseURL,
+ init: { headers }
+ };
+}