mirror of
https://github.com/stardrophere/InsightRadar.git
synced 2026-06-06 03:07:50 +08:00
13 lines
277 B
TypeScript
13 lines
277 B
TypeScript
const API_PREFIX = '/api/v1'
|
|
|
|
export function buildUrl(path: string): string {
|
|
if (!path.startsWith('/')) {
|
|
path = '/' + path
|
|
}
|
|
return `${API_PREFIX}${path}`
|
|
}
|
|
|
|
export async function fetchApi(path: string, init?: RequestInit) {
|
|
return fetch(buildUrl(path), init)
|
|
}
|