diff --git a/src/APIFunctions/Mailer.js b/src/APIFunctions/Mailer.js index 74415de73..e0c3370e2 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'; @@ -11,26 +10,27 @@ 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 + 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}`, }, - { - headers: { - Authorization: `Bearer ${token}` - } - }, - ) - .then((response) => { - status.responseData = response; - }) - .catch((error) => { - status.error = true; - status.responseData = error; + body: JSON.stringify({ + email, + }), }); + if (res.ok) { + status.responseData = true; + } else { + status.error = true; + } + } catch(error) { + status.error = true; + status.responseData = error; + } return status; } @@ -43,16 +43,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; }