api/user: remove 'return await'

This commit is contained in:
vchikalkin 2023-07-10 17:39:12 +03:00
parent f4190a5bba
commit d9d30ac45d

View File

@ -1,11 +1,19 @@
import { love } from './tools';
import type { User } from './types';
import getUrls from '@/config/urls';
import type { AxiosRequestConfig } from 'axios';
import type { AxiosError, AxiosRequestConfig } from 'axios';
import axios from 'axios';
const { URL_GET_USER } = getUrls();
export async function getUser(config?: AxiosRequestConfig) {
return await axios.get<User>(URL_GET_USER, config).then((res) => love(res.data));
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);
}
});
}