add refresh token in axios

This commit is contained in:
hamid zarghami
2025-11-22 14:03:52 +03:30
parent 6950e1c3ad
commit 23abb2c8eb
3 changed files with 99 additions and 6 deletions
+8 -2
View File
@@ -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;
};
+18
View File
@@ -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>;