feat : otp api changed
This commit is contained in:
@@ -32,13 +32,15 @@ function getStoredMobileNumber(): string | null {
|
||||
export async function sendOtp(payload: SendOtpPayload) {
|
||||
try {
|
||||
const mobileNumber = payload.mobileNumber || getStoredMobileNumber();
|
||||
const response = await axios.post(
|
||||
'http://localhost:8080/api/otp/send',
|
||||
{ ...payload, mobileNumber },
|
||||
{ headers: { 'Content-Type': 'application/json' } }
|
||||
);
|
||||
const response = await fetch('api/otp/send', {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ ...payload,mobileNumber}),
|
||||
})
|
||||
console.log('otp sended.');
|
||||
return response.data;
|
||||
return await response.json();
|
||||
} catch (error: any) {
|
||||
console.error('Error sending OTP:', error.response?.data || error.message);
|
||||
throw error.response?.data || error;
|
||||
@@ -48,13 +50,15 @@ export async function sendOtp(payload: SendOtpPayload) {
|
||||
export async function verifyOtp(otp: string) {
|
||||
try {
|
||||
const mobileNumber = getStoredMobileNumber();
|
||||
const response = await axios.post(
|
||||
`http://localhost:8080/api/otp/verify?mobileNumber=${mobileNumber}`,
|
||||
{ otp },
|
||||
{ headers: { 'Content-Type': 'application/json' } }
|
||||
);
|
||||
const response = await fetch(`/api/otp/verify?mobileNumber=${mobileNumber}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({otp}),
|
||||
})
|
||||
console.log('Otp verified');
|
||||
return response.data;
|
||||
return await response.json();
|
||||
} catch (error: any) {
|
||||
console.error('Error verifying OTP:', error.response?.data || error.message);
|
||||
throw error.response?.data || error;
|
||||
@@ -64,13 +68,15 @@ export async function verifyOtp(otp: string) {
|
||||
export async function verifyLoginOtp(otp: string, mobileNumber: string) {
|
||||
try {
|
||||
// const mobileNumber = getStoredMobileNumber();
|
||||
const response = await axios.post(
|
||||
`http://localhost:8080/api/otp/verify?mobileNumber=${mobileNumber}`,
|
||||
{ otp },
|
||||
{ headers: { 'Content-Type': 'application/json' } }
|
||||
);
|
||||
const response = await fetch(`/api/otp/verify?mobileNumber=${mobileNumber}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({otp}),
|
||||
})
|
||||
console.log('Otp verified.');
|
||||
return response.data;
|
||||
return await response.json();
|
||||
} catch (error: any) {
|
||||
console.error('Error verifying OTP:', error.response?.data || error.message);
|
||||
throw error.response?.data || error;
|
||||
|
||||
Reference in New Issue
Block a user