/
gnomdeployer
/
VUZPlus
Обзор
Документация
Войти
/
gnomdeployer
/
VUZPlus
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
master
client/src/api/auth.api.ts
75 строк
2 KB
unwelcome
rework api, rework directions and digital departments to programms, fix applications
13 май 2025, 19:19
13 май 2025, 19:19
4818e0a
Код
Авторство
О чём код?
import axios from "axios"; import { DEVMODE, API, type ISignUpStudent, type ISignUpDelegate, type ILogIn, type IUpdateProfile } from "@/helpers/constants"; import { GET_COOKIE } from "@/helpers/functions"; //GET// //POST// //POST create student account export function API_SignUpStudent(data: ISignUpStudent) { return new Promise((resolve, reject) => { axios.post(`${API}/sign-up`, data) .then(response => { if(DEVMODE) console.log('SignUpStudent request success: ', response); resolve(response); }) .catch(err => { if(DEVMODE) console.log('SignUpStudent request error: ', err); reject(err); }); }); } //POST create delegate account export function API_SignUpDelegate(data: ISignUpDelegate) { return new Promise((resolve, reject) => { axios.post(`${API}/sign-up/delegate`, data) .then(response => { if(DEVMODE) console.log('SignUpDelegate request success: ', response); resolve(response); }) .catch(err => { if(DEVMODE) console.log('SignUpDelegate request error: ', err); reject(err); }); }); } //POST login into account export function API_LogIn(data: ILogIn) { return new Promise((resolve, reject) => { axios.post(`${API}/login`, data) .then(response => { if(DEVMODE) console.log('LogIn request success: ', response); resolve(response); }) .catch(err => { if(DEVMODE) console.log('LogIn request error: ', err); reject(err); }); }); } //PUT// //PUT update account export function API_UpdateProfile(data: IUpdateProfile) { return new Promise((resolve, reject) => { axios.put(`${API}/auth/profile`, data, { headers: { Authorization: `Bearer ${GET_COOKIE('access_token')}`, } }) .then(response => { if(DEVMODE) console.log('Profile update success: ', response); resolve(response); }) .catch(err => { if(DEVMODE) console.log('Profile update error: ', err); reject(err); }); }); } //DELETE//