Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 5 additions & 2 deletions src/views/Restaurants.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -87,7 +90,7 @@ export default {
totalPage,
prev,
next
} = response.data
} = data

this.restaurants = restaurants
this.categories = categories
Expand Down
3 changes: 3 additions & 0 deletions src/views/RestaurantsFeeds.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/views/SignIn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down