diff --git a/web/src/api/verify.ts b/web/src/api/verify.ts new file mode 100644 index 0000000..edaf892 --- /dev/null +++ b/web/src/api/verify.ts @@ -0,0 +1,25 @@ +import { axios, handleApiError } from "."; + +export const requestEmailOtpApi = async (): Promise => { + const response = await axios.post("/api/v1/auth/email"); + + if (response.status !== 200 && response.status !== 201) + throw await handleApiError(response); + + return response.data; +}; + +export interface ConfirmEmailRequest { + otp: string; +} + +export const confirmEmailApi = async ( + req: ConfirmEmailRequest, +): Promise => { + const response = await axios.post("/api/v1/auth/email/otp", req); + + if (response.status !== 200 && response.status !== 201) + throw await handleApiError(response); + + return response.data; +};