Add send otp api
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// imports
|
||||
|
||||
import { useMutation } from "@tanstack/vue-query";
|
||||
import axios from "~/configs/axios.config";
|
||||
import { API_ENDPOINTS } from "~/constants";
|
||||
|
||||
// types
|
||||
|
||||
export type OtpRequest = {
|
||||
phone: string;
|
||||
};
|
||||
|
||||
// methods
|
||||
|
||||
export const handleOtp = async (variables: OtpRequest) => {
|
||||
const { data } = await axios.post<OtpRequest>(`${API_ENDPOINTS.account.send_otp}`, variables);
|
||||
return data;
|
||||
};
|
||||
|
||||
// composable
|
||||
|
||||
const useOtp = () => {
|
||||
return useMutation({
|
||||
mutationFn: (variables: OtpRequest) => handleOtp(variables)
|
||||
});
|
||||
};
|
||||
|
||||
export default useOtp;
|
||||
@@ -1,6 +1,9 @@
|
||||
export const API_ENDPOINTS = {
|
||||
account : {
|
||||
send_otp : "/accounts/send_otp",
|
||||
},
|
||||
auth: {
|
||||
login: "/token",
|
||||
signin: "/token",
|
||||
logout: "/accounts/logout",
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user