mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
23 lines
648 B
TypeScript
23 lines
648 B
TypeScript
import axios from "axios";
|
|
import { registerEvent } from "../register-event";
|
|
import { userProfileSchema } from "../helpers/validators";
|
|
import { logger } from "@main/services";
|
|
|
|
const getUserProfile = async (
|
|
_event: Electron.IpcMainInvokeEvent,
|
|
username: string
|
|
) => {
|
|
return axios
|
|
.get(`${process.env.API_URL}/profile/${username}`)
|
|
.then((response) => {
|
|
const profile = userProfileSchema.parse(response.data);
|
|
console.log(profile);
|
|
return profile;
|
|
})
|
|
.catch((err) => {
|
|
logger.error(`getUserProfile: ${username}`, err);
|
|
return null;
|
|
});
|
|
};
|
|
|
|
registerEvent("getUserProfiel", getUserProfile);
|