| 99 | } |
| 100 | |
| 101 | async logout() { |
| 102 | try { |
| 103 | const res = await fetch(`${config.API_BASE}/login`, { |
| 104 | method: "DELETE", |
| 105 | }); |
| 106 | if (!res.ok) { |
| 107 | throw new Error("Unable to logout."); |
| 108 | } |
| 109 | } catch (error) { |
| 110 | console.error("Error during logout:", error); |
| 111 | } |
| 112 | |
| 113 | loggedInUser = null; |
| 114 | localStorage.removeItem(CACHE_USER_KEY); |
| 115 | |
| 116 | try { |
| 117 | await this.#exec("logout"); |
| 118 | return true; |
| 119 | } catch (error) { |
| 120 | console.error("Failed to logout.", error); |
| 121 | return false; |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * @param {boolean} forceFetch |