import axios from "axios"; export interface SPUser { Id: number; Title: string; Email: string; LoginName: string; } const getWebUrl = () => (window as any)._spPageContextInfo?.webAbsoluteUrl || `${window.location.protocol}//${window.location.host}`; export async function getCurrentUser(): Promise { const res = await axios.get( `${getWebUrl()}/_api/web/currentuser`, { headers: { Accept: "application/json;odata=verbose" }, withCredentials: true } ); return res.data.d as SPUser; }