From bedf43af45d97a10a6f62b4f1bb21cd66fda1d71 Mon Sep 17 00:00:00 2001
From: aura <nw@moneybot.cc>
Date: Thu, 19 Feb 2026 19:57:10 +0100
Subject: empty moneyjsx site

---
 public/src/api.tsx | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 public/src/api.tsx

(limited to 'public/src/api.tsx')

diff --git a/public/src/api.tsx b/public/src/api.tsx
new file mode 100644
index 0000000..fa941ec
--- /dev/null
+++ b/public/src/api.tsx
@@ -0,0 +1,39 @@
+export const url = "https://forum.networkheaven.net/api/";
+
+export interface ReqParams {
+  method: string,
+  body?: string,
+}
+
+export async function post( endpoint: string, body: Object ) {
+  return await req( endpoint, {
+    method: "POST",
+    body: JSON.stringify( body ),
+  } );
+}
+
+export async function req( endpoint: string, params: ReqParams ) {
+  const res = await fetch( `${url}/${endpoint}`, {
+    method: params.method,
+    headers: {
+      "Content-Type": "application/json",
+    },
+    body: params.body,
+  } );
+
+  if( !res.ok ) {
+    let json = null;
+    try {
+      json = await res.json();
+    } catch( e: any ) {
+      throw new Error( "error contacting server" );
+    }
+
+    throw new Error( json.msg );
+  }
+
+  const json = await res.json();
+  if( json.status != 'ok' )
+    throw new Error( json.msg );
+  return json;
+}
-- 
cgit v1.2.3

