diff options
Diffstat (limited to 'src/lib/api.ts')
-rw-r--r-- | src/lib/api.ts | 14 |
1 files changed, 14 insertions, 0 deletions
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 + }); +} |