api/user: remove 'return await'
This commit is contained in:
parent
f4190a5bba
commit
d9d30ac45d
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user