use nuxt plugin instead of function
This commit is contained in:
parent
7efa425c85
commit
a2736a6385
@ -2,6 +2,7 @@ import type { AsyncData, UseFetchOptions } from '#app'
|
||||
|
||||
export function requestCore<DataT>(url: string, options: UseFetchOptions<DataT>) {
|
||||
// const config = useRuntimeConfig()
|
||||
const {$mitt} = useNuxtApp()
|
||||
return useFetch(url, {
|
||||
baseURL: "https://cantyonion.site",
|
||||
retry: false,
|
||||
@ -25,7 +26,7 @@ export function requestCore<DataT>(url: string, options: UseFetchOptions<DataT>)
|
||||
// }
|
||||
},
|
||||
onResponseError({ response }) {
|
||||
emitter.emit('eventBus', {
|
||||
$mitt.emit('eventBus', {
|
||||
level: 'error',
|
||||
title: `HTTP错误:${response.status}`,
|
||||
message: response.statusText
|
||||
|
Loading…
x
Reference in New Issue
Block a user