Correção perfil

This commit is contained in:
Matheus Albino Brunhara
2022-05-28 11:14:52 -05:00
parent a810fd066a
commit e79cb353b2
2 changed files with 63 additions and 26 deletions

View File

@@ -0,0 +1,35 @@
import * as usersRoutes from "../../services/api/users";
interface getByIdReturn {
userId?: string;
error?: boolean;
errorMessage?: string;
}
interface getByIdResponse {
status?: string;
message?: string;
userId?: string;
}
export const getById = async (userId: string): Promise<getByIdReturn> => {
try {
let res: getByIdResponse = await usersRoutes.getById(userId)
if (res.status === "error") {
return {
error: true,
errorMessage: res.message,
};
}
return {
userId: res.userId,
};
} catch(err) {
return {
error: true,
errorMessage: "Por favor, autentique-se.",
};
}
};