export class APIClient { constructor(baseURL = 'http://localhost:8001/api/v1') { this.baseURL = baseURL; this.login = this.login.bind(this); this.logout = this.logout.bind(this); this.me = this.me.bind(this); this.listUsers = this.listUsers.bind(this); this.listRequests = this.listRequests.bind(this); } login(username, password) { return this._callAPI('/login', { username, password }, 'POST') } logout() { return this._callAPI('/logout') } me() { return this._callAPI('/me') } listUsers() { return this._callAPI('/users') } listRequests() { } createRequest(request) { } updateRequestStatus(reqID, newStatus) { } _callAPI(path, body, method='GET') { return fetch(this.baseURL + path, { method, headers: { 'Content-Type': 'application/json', }, mode: 'cors', credentials: 'include', body: JSON.stringify(body), }) .then(res => res.json()) } }