This commit is contained in:
16
client/shared/chad-api.ts
Normal file
16
client/shared/chad-api.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { ToastEventBus } from 'primevue'
|
||||
|
||||
const instance = $fetch.create({
|
||||
baseURL: process.env.API_BASE_URL || '/api',
|
||||
credentials: 'include',
|
||||
onResponseError({ response }) {
|
||||
if (!import.meta.client)
|
||||
return
|
||||
|
||||
const message = response._data.error || 'Something went wrong'
|
||||
|
||||
ToastEventBus.emit('add', { severity: 'error', summary: 'Error', detail: message, closable: false, life: 3000 })
|
||||
},
|
||||
})
|
||||
|
||||
export default instance
|
||||
Reference in New Issue
Block a user