diff --git a/src/store/actions.js b/src/store/actions.js
index 0033257..1daf38c 100644
--- a/src/store/actions.js
+++ b/src/store/actions.js
@@ -2,8 +2,14 @@ import axios from "axios";
export default {
getFruits: async ({ commit }) => {
- const response = await axios.get("http://localhost:3000/fruit");
- commit("setFruits", response.data.data);
+ await axios
+ .get("http://localhost:3000/fruit")
+ .then(res => {
+ commit("setFruits", res.data.data);
+ })
+ .catch(err => {
+ if (err.message === "Network Error") throw "Check API connectivity ...";
+ });
},
getFruit: async ({ commit }, id) => {
const response = await axios.get(`http://localhost:3000/fruit/${id}`);
diff --git a/src/views/Fruit.vue b/src/views/Fruit.vue
index d8a9f20..30c6deb 100644
--- a/src/views/Fruit.vue
+++ b/src/views/Fruit.vue
@@ -128,7 +128,7 @@ article {
.alert {
margin-top: 1.75rem;
- background-color: lighten(@color-1, 10%);
+ background: linear-gradient(112.4deg, #1c9797 11.05%, #147171 89.93%);
color: @color-2;
padding: 1rem 1.5rem;
border-radius: 4px;
diff --git a/src/views/Fruits.vue b/src/views/Fruits.vue
index 95dd4f5..989e57e 100644
--- a/src/views/Fruits.vue
+++ b/src/views/Fruits.vue
@@ -1,7 +1,11 @@
Directory
-
+
+
+ {{ error }}
+
$ yarn run api
+
@@ -15,15 +19,45 @@ export default {
computed: {
...mapState(["fruits"])
},
+ data() {
+ return {
+ error: null
+ };
+ },
async created() {
- await this.$store.dispatch("getFruits");
+ await this.$store.dispatch("getFruits").catch(err => (this.error = err));
}
};
-