2023-07-10 17:39:12 +03:00

20 lines
550 B
TypeScript

import { love } from './tools';
import type { User } from './types';
import getUrls from '@/config/urls';
import type { AxiosError, AxiosRequestConfig } from 'axios';
import axios from 'axios';
const { URL_GET_USER } = getUrls();
export async function getUser(config?: AxiosRequestConfig) {
return axios
.get<User>(URL_GET_USER, config)
.then((res) => love(res.data))
.catch((error: AxiosError | Error) => {
if (axios.isAxiosError(error)) {
// TODO: track error
throw new Error(error.message);
}
});
}