File size: 434 Bytes
8d88d9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { base } from "$app/paths";
import type { Client } from "@gradio/client";

export type ApiReturnType = Awaited<ReturnType<typeof Client.prototype.view_api>>;

export async function getGradioApi(space: string) {
	const api: ApiReturnType = await fetch(`${base}/api/spaces-config?space=${space}`).then(
		async (res) => {
			if (!res.ok) {
				throw new Error(await res.text());
			}
			return res.json();
		}
	);
	return api;
}