summaryrefslogtreecommitdiff
path: root/src/components/header/authdialog/register.ts
diff options
context:
space:
mode:
authorl3wdfut4pwr <l3wdfut4pwr@gmail.com>2026-04-21 13:33:46 +0300
committerl3wdfut4pwr <l3wdfut4pwr@gmail.com>2026-04-21 13:33:46 +0300
commitc7d2526afec5ffb8918c20d7c1c58852f1c647bd (patch)
tree476fa2241c0febfcb353f61c4bfecf462b6a359f /src/components/header/authdialog/register.ts
parent8b2f7f4cbf7a59cc6c600299df1b1f67fccae93b (diff)
minor profile changes
Diffstat (limited to 'src/components/header/authdialog/register.ts')
-rw-r--r--src/components/header/authdialog/register.ts32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/components/header/authdialog/register.ts b/src/components/header/authdialog/register.ts
index 46a59f2..3098df7 100644
--- a/src/components/header/authdialog/register.ts
+++ b/src/components/header/authdialog/register.ts
@@ -45,14 +45,18 @@ export const registerUser = async (
try {
const res = await fetch(`${API_URL}/api/auth/register`, {
method: 'POST',
- headers: { 'Content-Type': 'application/json' },
+ headers: {
+ 'Content-Type': 'application/json',
+ },
body: JSON.stringify({ username, email, password }),
credentials: 'include',
});
if (!res.ok) {
- const data = await res.json();
- const { field, message } = data.detail || {};
+ const errorData = await res.json();
+
+ const { field, message } = errorData.detail || {};
+
return {
data: null,
error: field
@@ -61,20 +65,16 @@ export const registerUser = async (
};
}
- const meRes = await fetch(`${API_URL}/api/me`, {
- credentials: 'include',
- });
-
- if (!meRes.ok) {
- throw new Error(
- 'Не удалось получить данные пользователя после регистрации',
- );
- }
-
- const meData = await meRes.json();
+ const user = await res.json();
- return { data: meData, error: null };
+ return {
+ data: user,
+ error: null,
+ };
} catch (err: any) {
- return { data: null, error: { general: err.message } };
+ return {
+ data: null,
+ error: { general: err.message },
+ };
}
};