Files
parcer/src/api/auth.ts

16 lines
474 B
TypeScript
Raw Normal View History

2024-10-28 21:10:16 +05:30
import { default as axios } from "axios";
2024-11-01 08:25:14 +05:30
import { apiUrl } from "../apiConfig"
2024-10-28 21:10:16 +05:30
export const getUserById = async (userId: string) => {
try {
2024-11-01 08:25:14 +05:30
const response = await axios.get(`${apiUrl}/auth/user/${userId}`);
2024-10-28 21:10:16 +05:30
if (response.status === 200) {
return response.data;
} else {
throw new Error(`Couldn't get user with id ${userId}`);
}
} catch (error: any) {
console.error(error);
return null;
}
}