add refresh token in axios
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
type LoginWithPasswordType,
|
||||
type OtpVerifyType,
|
||||
type RefreshTokenType,
|
||||
type RefreshTokenResponse,
|
||||
type RegisterType,
|
||||
} from "../types/AuthTypes";
|
||||
|
||||
@@ -39,7 +40,12 @@ export const register = async (params: RegisterType) => {
|
||||
return data;
|
||||
};
|
||||
|
||||
export const refreshToken = async (params: RefreshTokenType) => {
|
||||
const { data } = await axios.post(`/auth/refresh`, params);
|
||||
export const refreshToken = async (
|
||||
params: RefreshTokenType
|
||||
): Promise<RefreshTokenResponse> => {
|
||||
const { data } = await axios.post<RefreshTokenResponse>(
|
||||
`/auth/refresh`,
|
||||
params
|
||||
);
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { type XOR } from "../../../helpers/types";
|
||||
import { type IResponse } from "../../../types/response.types";
|
||||
|
||||
export type LoginType = {
|
||||
phone_email: string;
|
||||
@@ -56,3 +57,20 @@ export type RegisterType = {
|
||||
export type RefreshTokenType = {
|
||||
refreshToken: string;
|
||||
};
|
||||
|
||||
export type AccessToken = {
|
||||
token: string;
|
||||
expire: number;
|
||||
};
|
||||
|
||||
export type RefreshToken = {
|
||||
token: string;
|
||||
expire: number;
|
||||
};
|
||||
|
||||
export type RefreshTokenResponseData = {
|
||||
accessToken: AccessToken;
|
||||
refreshToken: RefreshToken;
|
||||
};
|
||||
|
||||
export type RefreshTokenResponse = IResponse<RefreshTokenResponseData>;
|
||||
|
||||
Reference in New Issue
Block a user