diff --git a/src/store/index.js b/src/store/index.js index 7c7ba1e..5fb5d75 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -38,6 +38,9 @@ export default new Vuex.Store({ async fetchCurrentUser ({ commit }) { try { const { data } = await usersAPI.getCurrentUser() + if (data.status === 'error') { + throw new Error(data.message) + } const { id, name, email, image, isAdmin } = data diff --git a/src/views/Restaurants.vue b/src/views/Restaurants.vue index dd05a91..d377ef0 100644 --- a/src/views/Restaurants.vue +++ b/src/views/Restaurants.vue @@ -74,10 +74,13 @@ export default { async fetchRestaurants ({ queryPage, queryCategoryId }) { try { this.isLoading = true - const response = await restaurantsAPI.getRestaurants({ + const { data } = await restaurantsAPI.getRestaurants({ page: queryPage, categoryId: queryCategoryId }) + if (data.status === 'error') { + throw new Error(data.message) + } const { restaurants, @@ -87,7 +90,7 @@ export default { totalPage, prev, next - } = response.data + } = data this.restaurants = restaurants this.categories = categories diff --git a/src/views/RestaurantsFeeds.vue b/src/views/RestaurantsFeeds.vue index cfe2d31..8fd74e7 100644 --- a/src/views/RestaurantsFeeds.vue +++ b/src/views/RestaurantsFeeds.vue @@ -54,6 +54,9 @@ export default { try { this.isLoading = true const { data } = await restaurantsAPI.getFeeds() + if (data.status === 'error') { + throw new Error(data.message) + } const { restaurants, comments } = data this.restaurants = restaurants diff --git a/src/views/SignIn.vue b/src/views/SignIn.vue index 84d023c..232f86e 100644 --- a/src/views/SignIn.vue +++ b/src/views/SignIn.vue @@ -86,13 +86,11 @@ export default { this.isProcessing = true - const response = await authorizationAPI.signIn({ + const { data } = await authorizationAPI.signIn({ email: this.email, password: this.password }) - const { data } = response - if (data.status === 'error') { throw new Error(data.message) }