From 9c65a9c271dfda5ea17c9d909bc9e7e6d0c040ab Mon Sep 17 00:00:00 2001 From: l3wdfut4pwr Date: Fri, 3 Apr 2026 23:59:33 +0300 Subject: add profile --- src/lib/api/user.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/lib/api/user.ts (limited to 'src/lib/api/user.ts') 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(); +} -- cgit v1.3-3-g829e