Catch failure to get notes in home view
authorAdam Dullage <redacted>
Fri, 3 May 2024 08:05:32 +0000 (09:05 +0100)
committerAdam Dullage <redacted>
Fri, 3 May 2024 08:05:32 +0000 (09:05 +0100)
client/views/Home.vue

index f038938d86f5c10024b50db1f194860806ad536a..8857db2b6adbdcaf7e454f9172bc35e90b5ad820 100644 (file)
 </template>
 
 <script setup>
+import { useToast } from "primevue/usetoast";
 import { ref } from "vue";
+import { RouterLink } from "vue-router";
 
 import { getNotes } from "../api.js";
 import CustomButton from "../components/CustomButton.vue";
 import Logo from "../components/Logo.vue";
+import { getUnknownServerErrorToastOptions } from "../helpers.js";
 import SearchInput from "../partials/SearchInput.vue";
-import { RouterLink } from "vue-router";
 
 const notes = ref([]);
+const toast = useToast();
 
-getNotes("*", "lastModified", "desc", 5).then((data) => {
-  notes.value = data;
-});
+getNotes("*", "lastModified", "desc", 5)
+  .then((data) => {
+    notes.value = data;
+  })
+  .catch((error) => {
+    toast.add(getUnknownServerErrorToastOptions(error));
+  });
 </script>
git clone https://git.99rst.org/PROJECT