diff --git a/src/Api.ts b/src/Api.ts index fb021e5..1c38917 100644 --- a/src/Api.ts +++ b/src/Api.ts @@ -21,7 +21,11 @@ export class Api { this.baseURL = baseURL; this.authBaseURL = authBaseURL; this.publicBaseURL = publicBaseURL; - this.accessToken = accessToken ?? localStorage.getItem("access-token"); + try{ + this.accessToken = accessToken ?? localStorage?.getItem("access-token"); + } catch (e) { + this.accessToken = null; + } this.axios = axios.create({ baseURL }); this.axios.interceptors.request.use(({ headers = {}, ...config }) => ({ ...config, @@ -63,11 +67,20 @@ export class Api { return (await this.axiosPublic.get(`/users/${userId}/info`))?.data; } + async getSession() { + return (await this.axios.get(`/session`))?.data; + } + async createSession() { + return (await this.axios.post(`/session`))?.data; + } + async deleteSession() { + return (await this.axios.delete(`/session`))?.data; + } async joinSession(hostId: string) { return (await this.axios.post(`/session/join`, { hostId }))?.data; } - async leaveSession(hostId: string) { - return (await this.axios.post(`/session/session`, { hostId }))?.data; + async leaveSession() { + return (await this.axios.post(`/session/leave`))?.data; } } diff --git a/src/App.vue b/src/App.vue index a7a3ad8..beadaf7 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,5 +1,8 @@