From 568deef2bdc14f44bc06f2c547f8fe4c97886b78 Mon Sep 17 00:00:00 2001 From: DanielTQuach Date: Mon, 9 Jun 2025 01:32:37 -0700 Subject: [PATCH 1/3] mailer remove axios --- src/APIFunctions/Mailer.js | 66 ++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/src/APIFunctions/Mailer.js b/src/APIFunctions/Mailer.js index de4de98fa..57ad9c918 100644 --- a/src/APIFunctions/Mailer.js +++ b/src/APIFunctions/Mailer.js @@ -1,4 +1,3 @@ -import axios from 'axios'; import { ApiResponse } from './ApiResponses'; import { BASE_API_URL } from '../Enums'; @@ -12,25 +11,27 @@ import { BASE_API_URL } from '../Enums'; export async function sendVerificationEmail(email, token) { let status = new ApiResponse(); const url = new URL('/cloudapi/Auth/sendVerificationEmail', BASE_API_URL); - await axios - .post( - url.href, - { - email + try { + const res = await fetch(url.href, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}`, }, - { - headers: { - Authorization: `Bearer ${token}` - } - }, - ) - .then((response) => { - status.responseData = response; - }) - .catch((error) => { - status.error = true; - status.responseData = error; + body: JSON.stringify({ + email, + }), }); + if (res.ok) { + const result = await res.json(); + status.responseData = result; + } else { + status.error = true; + } + } catch(error) { + status.error = true; + status.responseData = error; + } return status; } @@ -43,16 +44,25 @@ export async function sendVerificationEmail(email, token) { export async function sendPasswordReset(email, captchaToken) { let status = new ApiResponse(); const url = new URL('/api/Auth/sendPasswordReset', BASE_API_URL); - await axios - .post(url.href, { - email, - captchaToken, - }) - .then((response) => { - status.responseData = response; - }) - .catch((error) => { - status.error = error; + try { + const res = await fetch(url.href, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + email, + captchaToken, + }), }); + if (res.ok) { + const result = await res.json(); + status.responseData = result; + } else { + status.error = true; + } + } catch(error) { + status.error = error; + } return status; } From 9641e513f716910e8f54da9c685f97fe673bf7be Mon Sep 17 00:00:00 2001 From: DanielTQuach Date: Sat, 21 Jun 2025 17:50:19 -0700 Subject: [PATCH 2/3] revert to first changes --- src/APIFunctions/Mailer.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/APIFunctions/Mailer.js b/src/APIFunctions/Mailer.js index efffd95e8..8075732b0 100644 --- a/src/APIFunctions/Mailer.js +++ b/src/APIFunctions/Mailer.js @@ -10,17 +10,13 @@ import { BASE_API_URL } from '../Enums'; */ export async function sendVerificationEmail(email, token) { let status = new ApiResponse(); - const url = new URL('/api/Auth/sendVerificationEmail', BASE_API_URL); - await axios - .post( - url.href, - { - email - }, - { - headers: { - Authorization: `Bearer ${token}` - } + const url = new URL('/api/Auth/resendVerificationEmail', BASE_API_URL); + try { + const res = await fetch(url.href, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${token}`, }, body: JSON.stringify({ email, From 2b7315547311c623bb2ed998e1fc3415362eaf41 Mon Sep 17 00:00:00 2001 From: DanielTQuach Date: Sat, 21 Jun 2025 18:09:06 -0700 Subject: [PATCH 3/3] fix responseData --- src/APIFunctions/Mailer.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/APIFunctions/Mailer.js b/src/APIFunctions/Mailer.js index 8075732b0..e0c3370e2 100644 --- a/src/APIFunctions/Mailer.js +++ b/src/APIFunctions/Mailer.js @@ -23,8 +23,7 @@ export async function sendVerificationEmail(email, token) { }), }); if (res.ok) { - const result = await res.json(); - status.responseData = result; + status.responseData = true; } else { status.error = true; }