BambitTestTask/api/httpClient.ts
alsaze 3d975d6884
All checks were successful
Deploy / build (push) Successful in 49s
Initial
2025-11-19 20:49:25 +03:00

22 lines
425 B
TypeScript

import { useToast } from '#imports'
const showToast = (description: string) => {
if (!import.meta.client)
return
const toast = useToast()
toast.add({
title: 'Uh oh! Something went wrong.',
description,
})
}
export const httpClient = $fetch.create({
onResponseError({ request, response }) {
const message = response?._data?.statusMessage ?? 'Something went wrong'
showToast(message)
},
})