import qs from "qs"; import { getAPIDummy } from "./http-config/axiosCustom"; import { httpGet, httpPost } from "./http-config/http-base-service"; import { httpGetInterceptor, httpGetInterceptorWithToken, httpPostInterceptor, } from "./http-config/http-interceptor-service"; export async function login(data: any) { const pathUrl = "signin"; const headers = { 'accept': 'application/json', 'content-type': 'application/json', }; return httpPost(pathUrl, headers, data); } // export async function login(data: any, csrfToken: string) { // const url = 'http://localhost:8080/mediahub/users/signin'; // try { // const response = await fetch(url, { // method: 'POST', // credentials: 'include', // headers: { // 'Content-Type': 'application/json', // 'X-XSRF-TOKEN': csrfToken || '' // } // }); // if (!response.ok) { // throw new Error(`HTTP error! status: ${response.status}`); // } // return response; // Menampilkan data yang diterima dari API // } catch (error) { // console.error('Fetch error: ', error); // } // } export async function getCsrfToken() { const pathUrl = "csrf"; const headers = { 'content-type': 'application/json', }; return httpGet(pathUrl, headers); // const url = 'https://netidhub.com/api/csrf'; // try { // const response = await fetch(url, { // method: 'GET', // credentials: 'include' // }); // if (!response.ok) { // throw new Error(`HTTP error! status: ${response.status}`); // } // const data = await response.json(); // console.log("csrf : ", data); // return data; // } catch (error) { // console.error('Fetch error: ', error); // } } export async function getProfile(token: any) { const url = "users/info"; return httpGetInterceptorWithToken(url, token); } export async function getInfoProfile() { const url = "users/info"; return httpGetInterceptor(url); } export async function setupPassword(data: any) { const url = "setup-password"; return httpPostInterceptor(url, data); } export async function saveUser(data: any) { const url = "users/save"; return httpPostInterceptor(url, data); }