42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import type * as t from './types';
|
|
import { urls } from '@/config/urls';
|
|
import wretch from 'wretch';
|
|
|
|
const api = wretch(urls.URL_UIS).errorType('json');
|
|
|
|
export async function getData(params: t.Request) {
|
|
const url = `/${params.slug}?${new URLSearchParams(params.searchParams)}`;
|
|
|
|
return api
|
|
.get(url)
|
|
.res<t.ResponseGetData>((cb) => cb.json())
|
|
.then((res) => res);
|
|
}
|
|
|
|
export async function getMetaData(params: t.Request) {
|
|
const url = `/${params.slug}/meta?${new URLSearchParams(params.searchParams)}`;
|
|
|
|
return api
|
|
.get(url)
|
|
.res<t.ResponseMetaData>((res) => res.json())
|
|
.then((res) => res);
|
|
}
|
|
|
|
export async function getConfig(params: t.Request) {
|
|
const url = `/${params.slug}/config`;
|
|
|
|
return api
|
|
.get(url)
|
|
.res<t.ResponseConfig>((res) => res.json())
|
|
.then((res) => res);
|
|
}
|
|
|
|
export async function getConditions(params: t.Request) {
|
|
const url = `/${params.slug}/conditions?${new URLSearchParams(params.searchParams)}`;
|
|
|
|
return api
|
|
.get(url)
|
|
.res<t.ResponseConditions>((res) => res.text())
|
|
.then((res) => res);
|
|
}
|