adding question before refetch data when error
This commit is contained in:
@@ -4,6 +4,7 @@ import axios from 'axios'
|
|||||||
import { usePage } from '@inertiajs/inertia-vue3'
|
import { usePage } from '@inertiajs/inertia-vue3'
|
||||||
import Builder from './Sidebar/Builder.vue'
|
import Builder from './Sidebar/Builder.vue'
|
||||||
import Icon from '@/Components/Icon.vue'
|
import Icon from '@/Components/Icon.vue'
|
||||||
|
import Swal from 'sweetalert2'
|
||||||
|
|
||||||
const self = getCurrentInstance()
|
const self = getCurrentInstance()
|
||||||
const menus = ref([])
|
const menus = ref([])
|
||||||
@@ -14,7 +15,15 @@ const fetch = async () => {
|
|||||||
const response = await axios.get(route('api.v1.user.menu', user.id))
|
const response = await axios.get(route('api.v1.user.menu', user.id))
|
||||||
return menus.value = response.data
|
return menus.value = response.data
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setTimeout(fetch, 1000)
|
const response = await Swal.fire({
|
||||||
|
title: 'Do you want to try again?',
|
||||||
|
text: `${e}`,
|
||||||
|
icon: 'error',
|
||||||
|
showCancelButton: true,
|
||||||
|
showCloseButton: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
response.isConfirmed && fetch()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,13 +22,15 @@ const fetch = async () => {
|
|||||||
const response = await axios.get(route('api.v1.superuser.permission'))
|
const response = await axios.get(route('api.v1.superuser.permission'))
|
||||||
permissions.value = response.data
|
permissions.value = response.data
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Swal.fire({
|
const response = await Swal.fire({
|
||||||
title: 'error',
|
title: 'Do you want to try again?',
|
||||||
text: `${e}`,
|
text: `${e}`,
|
||||||
icon: 'error',
|
icon: 'error',
|
||||||
|
showCancelButton: true,
|
||||||
|
showCloseButton: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
setTimeout(fetch, 2500)
|
response.isConfirmed && fetch()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user