From 365da080d8845694a2aeb3e45920249a4b52399f Mon Sep 17 00:00:00 2001 From: David Oduneye Date: Tue, 20 Feb 2024 00:05:41 -0500 Subject: [PATCH] fix ci + created register route --- frontend/sac-mobile/services/auth.ts | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/frontend/sac-mobile/services/auth.ts b/frontend/sac-mobile/services/auth.ts index b29a35068..2ba19af22 100644 --- a/frontend/sac-mobile/services/auth.ts +++ b/frontend/sac-mobile/services/auth.ts @@ -42,3 +42,33 @@ export const loginByEmail = async ( throw new Error('Error logging in'); } }; + +/** + * Registers the user with the given first name, last name, email, and password. + * @param firstName The first name of the user. + * @param lastName The last name of the user. + * @param email The email of the user. + * @param password The password of the user. + * @returns The user that was registered. + */ +export const register = async ( + firstName: string, + lastName: string, + email: string, + password: string +): Promise => { + try { + const response = await axios.post(`${API_BASE_URL}/users/`, { + firstName, + lastName, + email, + password, + college: 'KKCS', + year: '3', + }); + return response.data; + } catch (error) { + console.error(error); + throw new Error('Error registering'); + } +} \ No newline at end of file