From 156f4222d7e9b1c6703747e002524e9bf89a6146 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Thu, 13 Feb 2025 05:42:00 -0800 Subject: [PATCH] Modify users#info endpoint to send username (#426) --- components/auth/LoginModal/index.tsx | 8 ++++---- components/auth/SignupModal/index.tsx | 8 ++++---- utils/api.tsx | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/components/auth/LoginModal/index.tsx b/components/auth/LoginModal/index.tsx index 16ffa62f..21288f3a 100644 --- a/components/auth/LoginModal/index.tsx +++ b/components/auth/LoginModal/index.tsx @@ -111,9 +111,9 @@ const LoginModal = (props: Props) => { .login(body) .then((response) => { storeCookieInfo(response) - return response.data.user.id + return response.data.user.username }) - .then((id) => fetchUserInfo(id)) + .then((username) => fetchUserInfo(username)) .then((infoResponse) => storeUserInfo(infoResponse)) .catch((error: Error | AxiosError) => { if (axios.isAxiosError(error)) { @@ -131,8 +131,8 @@ const LoginModal = (props: Props) => { } } - function fetchUserInfo(id: string) { - return api.userInfo(id) + function fetchUserInfo(username: string) { + return api.userInfo(username) } function storeCookieInfo(response: AxiosResponse) { diff --git a/components/auth/SignupModal/index.tsx b/components/auth/SignupModal/index.tsx index d9c62279..2ee36e1d 100644 --- a/components/auth/SignupModal/index.tsx +++ b/components/auth/SignupModal/index.tsx @@ -85,9 +85,9 @@ const SignupModal = (props: Props) => { .create(body) .then((response) => { storeCookieInfo(response) - return response.data.id + return response.data.username }) - .then((id) => fetchUserInfo(id)) + .then((username) => fetchUserInfo(username)) .then((infoResponse) => storeUserInfo(infoResponse)) } @@ -109,8 +109,8 @@ const SignupModal = (props: Props) => { setHeaders() } - function fetchUserInfo(id: string) { - return api.userInfo(id) + function fetchUserInfo(username: string) { + return api.userInfo(username) } function storeUserInfo(response: AxiosResponse) { diff --git a/utils/api.tsx b/utils/api.tsx index 8508e197..dbc2d437 100644 --- a/utils/api.tsx +++ b/utils/api.tsx @@ -199,8 +199,8 @@ class Api { }) } - userInfo(id: string) { - const resourceUrl = `${this.url}/users/info/${id}` + userInfo(username: string) { + const resourceUrl = `${this.url}/users/info/${username}` return axios.get(resourceUrl) }