mirror of
https://github.com/ThisIsBenny/wishlist-app.git
synced 2025-06-07 05:57:41 +00:00
fix typescript error
Signed-off-by: Benny Samir Hierl <bennysamir@posteo.de>
This commit is contained in:
parent
c15b97d08a
commit
43aaa3efa2
2 changed files with 8 additions and 5 deletions
|
@ -9,6 +9,10 @@ import { ref } from 'vue'
|
||||||
import router from '../router'
|
import router from '../router'
|
||||||
import useAuth from './useAuth'
|
import useAuth from './useAuth'
|
||||||
|
|
||||||
|
export interface CustomAxiosError extends AxiosError {
|
||||||
|
ignore: boolean
|
||||||
|
}
|
||||||
|
|
||||||
const { token } = useAuth()
|
const { token } = useAuth()
|
||||||
const isLoading = ref(false)
|
const isLoading = ref(false)
|
||||||
const error = ref<any | null>(null)
|
const error = ref<any | null>(null)
|
||||||
|
@ -33,7 +37,7 @@ export const requestInterceptor = client.interceptors.request.use(
|
||||||
|
|
||||||
return config
|
return config
|
||||||
},
|
},
|
||||||
(err: AxiosError): Promise<AxiosError> => {
|
(err: CustomAxiosError): Promise<CustomAxiosError> => {
|
||||||
isLoading.value = false
|
isLoading.value = false
|
||||||
error.value = err
|
error.value = err
|
||||||
return Promise.reject(err)
|
return Promise.reject(err)
|
||||||
|
@ -45,7 +49,7 @@ export const responseInterceptor = client.interceptors.response.use(
|
||||||
isLoading.value = false
|
isLoading.value = false
|
||||||
return response
|
return response
|
||||||
},
|
},
|
||||||
(err: AxiosError): Promise<AxiosError> => {
|
(err: CustomAxiosError): Promise<CustomAxiosError> => {
|
||||||
isLoading.value = false
|
isLoading.value = false
|
||||||
if (err.response?.status === 404) {
|
if (err.response?.status === 404) {
|
||||||
router.push({ name: 'notFound' })
|
router.push({ name: 'notFound' })
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import useAxios from '@/composables/useAxios'
|
import useAxios, { CustomAxiosError } from '@/composables/useAxios'
|
||||||
import { Wishlist, WishlistItem } from '@/types'
|
import { Wishlist, WishlistItem } from '@/types'
|
||||||
import { AxiosError } from 'axios'
|
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
const { client } = useAxios()
|
const { client } = useAxios()
|
||||||
|
|
||||||
|
@ -11,7 +10,7 @@ const fetch = async (slugText: string): Promise<void> => {
|
||||||
const { data } = await client.get(`/wishlist/${slugText}`)
|
const { data } = await client.get(`/wishlist/${slugText}`)
|
||||||
state.value = data
|
state.value = data
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
if (e.isAxiosError && !(<AxiosError>e.ignore)) {
|
if (e.isAxiosError && !(<CustomAxiosError>e.ignore)) {
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue