| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- import { get } from "../config/request";
- import axiosAPI from "../config/axios";
- export const login = async (username, password) => {
- const data = {
- username,
- password,
- };
- const response = await axiosAPI.post("/auth/login", data, {
- headers: {
- "Content-Type": "application/json",
- },
- });
- return response.data;
- };
- export const refreshToken = async () => {
- try {
- const response = await axiosAPI.get("/token");
- return response.data;
- } catch (error) {
- if (error.response) return error.response.data;
- }
- };
- export const getUser = async () => {
- try {
- const response = await get("/user");
- return response.data;
- } catch (error) {
- if (error.response) return error.response.data;
- }
- };
- export const logout = async () => {
- try {
- const response = await axiosAPI.delete("/auth/logout");
- return response.data;
- } catch (error) {
- if (error.response) return error.response.data;
- }
- };
- export const loginToPt = async (lembaga_id, password) => {
- const data = {
- lembaga_id,
- password,
- };
- const response = await axiosAPI.post("/auth/login-to-pt", data, {
- headers: {
- "Content-Type": "application/json",
- },
- });
- return response.data;
- };
|