41 lines
938 B
TypeScript
41 lines
938 B
TypeScript
import { useConfig } from '@abearxiong/use-config';
|
|
|
|
const { resources, api } = useConfig<{
|
|
resources: string;
|
|
api: { host: string };
|
|
}>();
|
|
|
|
export const fetchTest = async (id: string) => {
|
|
const fetchUrl = 'http://' + api.host + '/api/router';
|
|
const fetchRes = await fetch(fetchUrl, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({
|
|
path: 'user-app',
|
|
key: 'test',
|
|
id: id,
|
|
}),
|
|
}).then((res) => res.json());
|
|
return fetchRes;
|
|
};
|
|
|
|
export const fetchDomain = async (domain: string) => {
|
|
const fetchUrl = 'http://' + api.host + '/api/router';
|
|
const fetchRes = await fetch(fetchUrl, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({
|
|
path: 'app',
|
|
key: 'getDomainApp',
|
|
data: {
|
|
domain,
|
|
},
|
|
}),
|
|
}).then((res) => res.json());
|
|
return fetchRes;
|
|
};
|