Removed axios and use custom useFetch
parent
e26dc65657
commit
9747b39df4
@ -1,8 +0,0 @@
|
||||
import axios from 'axios'
|
||||
|
||||
const request = axios.create({
|
||||
baseURL: 'http://localhost:8080',
|
||||
withCredentials: true,
|
||||
})
|
||||
|
||||
export { request }
|
||||
@ -0,0 +1,25 @@
|
||||
import type { UseFetchOptions } from 'nuxt/app'
|
||||
|
||||
const useCustomFetch = async <T>(
|
||||
path: string,
|
||||
options: UseFetchOptions<T> = {}
|
||||
) => {
|
||||
let headers: any = {}
|
||||
const token = useCookie('XSRF-TOKEN')
|
||||
|
||||
if (token.value) {
|
||||
headers['X-XSRF-TOKEN'] = token.value as string
|
||||
}
|
||||
|
||||
return useFetch('http://localhost:8080' + path, {
|
||||
credentials: 'include',
|
||||
watch: false,
|
||||
...options,
|
||||
headers: {
|
||||
...headers,
|
||||
...options?.headers,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export { useCustomFetch }
|
||||
Loading…
Reference in New Issue