diff --git a/src/api/auth.ts b/src/api/auth.ts new file mode 100644 index 00000000..34ebcab8 --- /dev/null +++ b/src/api/auth.ts @@ -0,0 +1,15 @@ +import { default as axios } from "axios"; + +export const getUserById = async (userId: string) => { + try { + const response = await axios.get(`http://localhost:8080/auth/user/${userId}`); + 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; + } +} \ No newline at end of file