From 8f5278eb443864910dd9c2131c992d71e3af2d20 Mon Sep 17 00:00:00 2001 From: kartofen Date: Fri, 26 Aug 2022 23:54:17 +0300 Subject: Big bang --- src/lib/api.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/lib/api.ts (limited to 'src/lib/api.ts') diff --git a/src/lib/api.ts b/src/lib/api.ts new file mode 100644 index 0000000..221a7b3 --- /dev/null +++ b/src/lib/api.ts @@ -0,0 +1,14 @@ +const base = 'https://localhost:5001/api' + +export async function api(method: string, resource: string, data?: any) { + console.log("API USED", method, resource, data); + + + return await fetch(`${base}/${method}/${resource}`, { + method, + headers: { + 'content-type': 'application/json' + }, + body: data + }); +} -- cgit v1.2.3