Ver Fonte

fix: No errors with empty studenthub data in browser

Sean Blackburn há 10 meses atrás
pai
commit
ef9d740afd
1 ficheiros alterados com 4 adições e 2 exclusões
  1. 4 2
      src/stores/studenthub.ts

+ 4 - 2
src/stores/studenthub.ts

@@ -83,7 +83,9 @@ export const useStudenthubStore = defineStore("studenthub", {
   actions: {
     loadData() {
       try {
-        this.student = JSON.parse(localStorage[STUDENTHUB_STUDENT_DATA]);
+        this.student = JSON.parse(
+          localStorage[STUDENTHUB_STUDENT_DATA] ?? "null",
+        );
       } catch (e) {
         console.info("Failed to parse the studenthub student data!");
         console.error(e);
@@ -91,7 +93,7 @@ export const useStudenthubStore = defineStore("studenthub", {
 
       try {
         this.applications = JSON.parse(
-          localStorage[STUDENTHUB_APPLICATIONS_DATA],
+          localStorage[STUDENTHUB_APPLICATIONS_DATA] ?? "null",
         );
       } catch (e) {
         console.info("Failed to parse the studenthub applications data!");