mirror of
https://github.com/Nezumi-2711/Sink.git
synced 2026-09-22 20:00:55 +00:00
feat: init
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { defu } from 'defu'
|
||||
import { toast } from 'vue-sonner'
|
||||
|
||||
export function useAPI(api: string, options?: object): Promise<unknown> {
|
||||
return $fetch(api, defu(options || {}, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${localStorage.getItem('SinkSiteToken') || ''}`,
|
||||
},
|
||||
})).catch((error) => {
|
||||
if (error?.data?.statusMessage) {
|
||||
toast(error?.data?.statusMessage)
|
||||
}
|
||||
return Promise.reject(error)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user