From 484f3ff6ab23e44395d090323b7f533c832ec727 Mon Sep 17 00:00:00 2001 From: roushou Date: Sun, 23 Jun 2024 03:21:40 +0700 Subject: [PATCH] feat(utils): add http `get` method --- packages/utils/http.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/utils/http.ts b/packages/utils/http.ts index 28c0d1a..ca1e835 100644 --- a/packages/utils/http.ts +++ b/packages/utils/http.ts @@ -2,6 +2,21 @@ const baseHeaders: HeadersInit = { "Content-Type": "application/json", }; +export async function get( + url: string, + options?: Omit, +): Promise { + const resp = await fetch(url, { + method: "GET", + ...options, + headers: { + ...baseHeaders, + ...options?.headers, + }, + }); + return (await resp.json()) as TResponse; +} + export async function post( url: string, options?: Omit,