Skip to content

Commit

Permalink
Cache plan data in local storage
Browse files Browse the repository at this point in the history
  • Loading branch information
alex9smith committed Nov 21, 2024
1 parent 8d9b2b9 commit ca3191d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions frontend/src/services/apiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ class ApiClient {
}

async getPlan() {
const cached = this.#getCachedItem("plan");
if (cached) {
return cached;
}
const plan = await this.#getUrl("/plan");
this.#cacheItem("plan", plan.plan);
return plan.plan;
}

Expand All @@ -82,8 +87,7 @@ class ApiClient {
if (!response.ok) {
throw new Error(`Response status: ${response.status}`);
}

return await response.json();
this.#cacheItem("plan", plan);
}
}

Expand Down

0 comments on commit ca3191d

Please sign in to comment.