hilingriviw/src/services/users.ts
2023-10-04 19:55:03 +07:00

24 lines
667 B
TypeScript

import { AxiosError } from "axios";
import { GET_CURRENT_USER_STATS } from "../constants/api";
import { IHttpResponse } from "../types/common";
import { client } from "./config";
async function getUserStatsService(): Promise<IHttpResponse> {
const newState: IHttpResponse = { data: null, error: null };
try {
const res = await client({ method: 'GET', url: GET_CURRENT_USER_STATS, withCredentials: true})
newState.data = res.data
newState.status = res.status
return newState
} catch(error) {
let err = error as AxiosError
newState.error = err
newState.status = err.status
throw(newState)
}
}
export {
getUserStatsService,
}