diff --git a/components/search/Search.tsx b/components/search/Search.tsx
index dbf4ed9..37a1e1a 100644
--- a/components/search/Search.tsx
+++ b/components/search/Search.tsx
@@ -164,9 +164,9 @@ const Search = () => {
try {
const universityParam = university;
const geParam = !ge.includes("GE") ? ge : ge.split(" ")[1];
- const data = await queryDatabase(universityParam, geParam);
+ const courses = await queryDatabase(universityParam, geParam);
- setCourses(data.courses);
+ setCourses(courses);
setLoading(false);
setError(false);
@@ -287,7 +287,7 @@ const Search = () => {
searchGE={ge}
/>
-
+
Search Filters
@@ -317,7 +317,7 @@ const Search = () => {
-
+
Sort By:
= {};
+
+export async function queryDatabase(
+ university: string,
+ ge: string,
+): Promise {
+ console.log(cache);
+ if (cache[university + ge]) {
+ return cache[university + ge];
+ }
+
const universityParam = encodeURIComponent(university);
const geParam = encodeURIComponent(ge);
@@ -11,7 +23,10 @@ export async function queryDatabase(university: string, ge: string) {
}
const data = await response.json();
- return data;
+
+ cache[university + ge] = data.courses;
+
+ return data.courses;
} catch (error) {
console.error("Error:", error);
throw error;