summaryrefslogtreecommitdiff
path: root/src/lib/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/api')
-rw-r--r--src/lib/api/user.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/lib/api/user.ts b/src/lib/api/user.ts
new file mode 100644
index 0000000..86dfce8
--- /dev/null
+++ b/src/lib/api/user.ts
@@ -0,0 +1,13 @@
+const API_URL = process.env.NEXT_PUBLIC_API_URL;
+
+export async function getUserByUsername(username: string) {
+ if (!username) throw new Error('Username is required');
+
+ const res = await fetch(`${API_URL}/api/users/${username}`, {
+ cache: 'no-store',
+ });
+
+ if (!res.ok) throw new Error(`User not found: ${username}`);
+
+ return res.json();
+}