add router
This commit is contained in:
@@ -2,11 +2,13 @@ import { useConfig } from '@abearxiong/use-config';
|
||||
|
||||
const { resources, api } = useConfig<{
|
||||
resources: string;
|
||||
api: { host: string };
|
||||
api: { host: string; path: string };
|
||||
ƒ;
|
||||
}>();
|
||||
|
||||
const apiPath = api.path || '/api/router';
|
||||
export const fetchTest = async (id: string) => {
|
||||
const fetchUrl = 'http://' + api.host + '/api/router';
|
||||
const fetchUrl = 'http://' + api.host + apiPath;
|
||||
const fetchRes = await fetch(fetchUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -22,7 +24,7 @@ export const fetchTest = async (id: string) => {
|
||||
};
|
||||
|
||||
export const fetchDomain = async (domain: string) => {
|
||||
const fetchUrl = 'http://' + api.host + '/api/router';
|
||||
const fetchUrl = 'http://' + api.host + apiPath;
|
||||
const fetchRes = await fetch(fetchUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -38,3 +40,22 @@ export const fetchDomain = async (domain: string) => {
|
||||
}).then((res) => res.json());
|
||||
return fetchRes;
|
||||
};
|
||||
|
||||
export const fetchApp = async ({ user, app }) => {
|
||||
const fetchUrl = 'http://' + api.host + apiPath;
|
||||
const fetchRes = await fetch(fetchUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
path: 'app',
|
||||
key: 'getApp',
|
||||
data: {
|
||||
user,
|
||||
key: app,
|
||||
},
|
||||
}),
|
||||
}).then((res) => res.json());
|
||||
return fetchRes;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user