feat: get user by id
This commit is contained in:
15
src/api/auth.ts
Normal file
15
src/api/auth.ts
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user