summaryrefslogtreecommitdiff
path: root/src/lib/api/user.ts
diff options
context:
space:
mode:
authorl3wdfut4pwr <l3wdfut4pwr@gmail.com>2026-04-03 23:59:33 +0300
committerl3wdfut4pwr <l3wdfut4pwr@gmail.com>2026-04-03 23:59:33 +0300
commit9c65a9c271dfda5ea17c9d909bc9e7e6d0c040ab (patch)
tree9df45f5df63fb509e1b7cdac81659c4713287d70 /src/lib/api/user.ts
parent1d20080db8a26e4b7dd4071daac1166142592afa (diff)
add profile
Diffstat (limited to 'src/lib/api/user.ts')
-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();
+}