2023-05-29 05:22:36 +00:00
|
|
|
// request.ts
|
|
|
|
|
2023-06-08 10:33:30 +00:00
|
|
|
export async function request<T>(
|
2023-05-29 05:22:36 +00:00
|
|
|
url: string,
|
|
|
|
options: RequestInit = {}
|
2023-06-08 10:33:30 +00:00
|
|
|
): Promise<T> {
|
2023-05-29 05:22:36 +00:00
|
|
|
const response = await fetch(url, options)
|
2023-06-08 10:33:30 +00:00
|
|
|
const data = await response.json()
|
|
|
|
return data as T
|
2023-05-29 05:22:36 +00:00
|
|
|
}
|